예제 #1
0
 public static bool Change(Original::Timer t, long dueTime, long period)
 {
     return(Helper.SimpleWrap <bool>(
                delegate(ClrSyncManager manager)
     {
         if (dueTime < 0 && dueTime != Timeout.Infinite)
         {
             throw new ArgumentOutOfRangeException();
         }
         if (period < 0 && period != Timeout.Infinite)
         {
             throw new ArgumentOutOfRangeException();
         }
         // lookup the timer
         TimerHelpers.TimerRoutineArg tra;
         if (TimerHelpers.timer2tra.TryGetValue(t, out tra))
         {
             if (!tra.disposed)
             {
                 tra.dueTime = new TimeSpan(dueTime);
                 tra.Period = new TimeSpan(period);
                 if (tra.inLoop)
                 {
                     // reuse the current worker thread, which is still executing
                     tra.changed = true;
                 }
                 else
                 {
                     // create a new work thread
                     t.Change(0, Timeout.Infinite);
                     int child = manager.TaskFork();
                     tra.parentSemaphore.WaitOne();
                     manager.RegisterTaskSemaphore(child, tra.selfSemaphore, false);
                     manager.TaskResume(child);
                 }
                 return false;
             }
             else
             {
                 return true;
             }
         }
         else
         {
             return t.Change(dueTime, period);
         }
     },
                delegate() { return t.Change(dueTime, period); }));
 }
예제 #2
0
 public static void Dispose(Original::Timer t)
 {
     Helper.SimpleWrap <bool>(
         delegate(ClrSyncManager manager) {
         t.Dispose();
         TimerHelpers.TimerRoutineArg tra;
         if (!TimerHelpers.timer2tra.TryGetValue(t, out tra))
         {
             // TODO: this is very bad. We have an untracked Timer!
             return(true);
         }
         tra.disposed = true;
         return(true);
     },
         delegate() { t.Dispose(); return(true); }
         );
 }
예제 #3
0
 public static bool Change(Original::Timer t, uint dueTime, uint period)
 {
     return(Change(t, (long)dueTime, (long)period));
 }
예제 #4
0
 public static bool Change(Original::Timer t, TimeSpan dueTime, TimeSpan period)
 {
     return(Change(t, (long)dueTime.TotalMilliseconds, (long)period.TotalMilliseconds));
 }
예제 #5
0
 public static bool Dispose(Original::Timer t, Original::WaitHandle h)
 {
     throw new NotImplementedException("Timer.Dispose(WaitHandle)");
 }