Пример #1
0
 internal void InternalRun()
 {
     FCurrent = this;
     try
     {
         this.OnStarted();
         try
         {
             this.FStatus = TaskStatus.Running;
             this.Run();
             this.FStatus = ((this.FInternalState & InternalState.CancellationConfirmed) > 0) ? TaskStatus.Canceled : TaskStatus.RanToCompletion;
         }
         catch (OperationCanceledException)
         {
             this.FStatus = TaskStatus.Canceled;
         }
         catch (System.Exception exception)
         {
             this.FException = exception;
             this.FStatus = TaskStatus.Faulted;
             if (!this.OnError(exception))
             {
                 throw;
             }
         }
         finally
         {
             this.OnFinished();
         }
     }
     finally
     {
         FCurrent = null;
     }
 }
Пример #2
0
 public override void QueueTask(SimpleTask item)
 {
     base.Queue.Enqueue(item);
     if (!this.IdleEventAssigned)
     {
         Application.Idle += new EventHandler(this.ApplicationIdle);
         this.IdleEventAssigned = true;
     }
 }
 public override void QueueTask(SimpleTask item)
 {
     lock (base.Queue)
     {
         base.Queue.Enqueue(item);
         if (!this.InProgress)
         {
             this.InProgress = true;
             this.StartWorkThread();
         }
         else
         {
             Monitor.Pulse(base.Queue);
         }
     }
 }