Ejemplo n.º 1
0
 /// <summary>
 /// 其他线程中可用等待获取的任务结果
 /// </summary>
 /// <param name="waitAction">结果</param>
 /// <returns>返回成功失败</returns>
 public bool Wait(out WaitAction waitAction)
 {
     if (this.IsCompleted)
     {
         waitAction = this;
         return(true);
     }
     if (this.IsWait)
     {
         throw new Exception("当前任务已经处于等待状态!");
     }
     this.IsWait = true;
     if (this.WaitHandle.WaitOne(this.WaitTimeout))
     {
         waitAction = this;
         return(true);
     }
     else
     {
         this.Exception   = new Exception("当前等待超时,稍后依然会完成!");
         this.IsException = true;
     }
     this.IsWait = false;
     waitAction  = this;
     return(false);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加队列任务
 /// </summary>
 /// <param name="waitaction">任务对象</param>
 public static void Add(WaitAction waitaction)
 {
     ActionQueue.queue.Enqueue(waitaction);
     ActionQueue.PerformTask();
 }