コード例 #1
0
 /// <summary>
 /// Enqueues action on to context after timer elapses.
 /// </summary>
 /// <param name="action"></param>
 /// <param name="firstInMs"></param>
 /// <returns></returns>
 public IDisposable Schedule(Action action, long firstInMs)
 {
     if (firstInMs <= 0)
     {
         var pending = new PendingAction(action);
         _executionContext.Enqueue(new Action(pending.Execute));
         return(pending);
     }
     else
     {
         var pending = new TimerAction(action, firstInMs, Timeout.Infinite);
         AddPending(pending);
         return(pending);
     }
 }