Beispiel #1
0
 def shower():                                                           
    with cls(*args) as form:
       Monitor.Enter(cls)
       try:
          cls.newform = form
          Monitor.Pulse(cls)
       finally:
          Monitor.Exit(cls)
       def exception_handler(sender, event):
          log.handle_error(event.Exception)  
       Application.ThreadException +=\
          ThreadExceptionEventHandler(exception_handler)
       Application.Run(form) # start form on new App thread; blocks
 def submit(self, task):
    '''
    Submits the given task (a method handle) to this Scheduler, to be run on 
    the background thread. if the Scheduler is idle, the given task will be 
    run almost immediately.  If the Scheduler is busy, the given task will be 
    run as soon as the Scheduler finishes its current task, UNLESS a new task 
    is added before the given task has a chance to start.  In that case, the 
    new task will take the given task's place in line, and the given task will
    never be executed. 
    
    If this Scheduler has been shutdown, the given task will never be run.
    '''
     
    if task:
       Monitor.Enter(self)
       try:
          if self.task != self:
             # notice this replace any task that is waiting to be run
             self.task = task
          Monitor.Pulse(self)
       finally:
          Monitor.Exit(self)