# title: demo the usage of the monitor.
# This is a demo of the monitor object which is available to users to
# provide feedback in scripts.  

import java.lang.Thread

monitor.setTaskSize(100)

monitor.started()

for i in xrange(100):
  if ( i>50 ):
     if ( monitor.isCancelled() ):
        raise Exception('Interrupted')
  monitor.setTaskProgress(i)
  if ( i==20 ):
     monitor.setProgressMessage('at 20' )
  if ( i==90 ):
     monitor.setProgressMessage('almost done' )
  java.lang.Thread.sleep(100)
