public IDisposable Schedule(TimeSpan dueTime, Action action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            //実行する時間を決定
            var doTime = Time + Scheduler.Normalize(dueTime);
            var item   = new ScheduledItem(action, doTime);

            lock (lockObject)
            {
                schedulerQueue.Enqueue(item);
            }

            return(item.Cancellation);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Removes the specified work item from the scheduler queue.
 /// </summary>
 /// <param name="scheduledItem">Work item to be removed from the scheduler queue.</param>
 /// <returns>true if the item was found; false otherwise.</returns>
 public bool Remove(ScheduledItem scheduledItem)
 {
     return(_queue.Remove(scheduledItem));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Enqueues the specified work item to be scheduled.
 /// </summary>
 /// <param name="scheduledItem">Work item to be scheduled.</param>
 public void Enqueue(ScheduledItem scheduledItem)
 {
     _queue.Enqueue(scheduledItem);
 }