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); })); }
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); } ); }
public static bool Change(Original::Timer t, uint dueTime, uint period) { return(Change(t, (long)dueTime, (long)period)); }
public static bool Change(Original::Timer t, TimeSpan dueTime, TimeSpan period) { return(Change(t, (long)dueTime.TotalMilliseconds, (long)period.TotalMilliseconds)); }
public static bool Dispose(Original::Timer t, Original::WaitHandle h) { throw new NotImplementedException("Timer.Dispose(WaitHandle)"); }