示例#1
0
        /// <summary>
        /// 出队列
        /// </summary>
        /// <returns></returns>
        public TaskType Dequeue()
        {
            lock (this)
            {
                if (taskQueue == null)
                {
                    return(default(TaskType));
                }

                lock (taskQueue)
                {
                    if (taskQueue.Count == 0)
                    {
                        return(default(TaskType));
                    }

                    TaskType t = taskQueue[0];
                    taskQueue.RemoveAt(0);
                    if (t != null && TaskQueueChanged != null)
                    {
                        TaskQueueChanged.Invoke(this, null);
                    }
                    return(t);
                }
            }
        }
示例#2
0
 /// <summary>
 /// 插队
 /// </summary>
 /// <param name="t"></param>
 public void Jumpqueue(TaskType t)
 {
     lock (taskQueue)
     {
         if (TaskAdding != null)
         {
             TaskAdding.Invoke(this, new TaskAddingEventArgs()
             {
                 Task = t, Index = 0
             });
         }
         taskQueue.Insert(0, t);
         if (TaskQueueChanged != null)
         {
             TaskQueueChanged.Invoke(this, null);
         }
     }
 }
示例#3
0
 /// <summary>
 /// 入队列
 /// </summary>
 /// <param name="t"></param>
 public void Enqueue(TaskType t)
 {
     lock (taskQueue)
     {
         if (TaskAdding != null)
         {
             TaskAdding.Invoke(this, new TaskAddingEventArgs()
             {
                 Task = t, Index = taskQueue.Count
             });
         }
         taskQueue.Add(t);
         if (TaskQueueChanged != null)
         {
             TaskQueueChanged.Invoke(this, null);
         }
     }
     IsTaskQueueCompleted = false;
 }