// The main server loop public void MainLoop() { basePeriod = 1; period = basePeriod; var timerQueue = new TimerQueue(); stopWatch.Start(); mainLoopTimer = timerQueue.CreateTimer(s => { RunLoop(); }, null, 0, period); while (Active) { are.WaitOne(-1); DoMainLoopStuff(); } /* TimerCallback tcb = RunLoop; * var due = 1;// (long)ServerRate / 3; * stopWatch.Start(); //Start the clock * mainLoopTimer = new Timer(tcb, are, 0, due); * are.WaitOne(-1);*/ }
public void CountdownTimerTest() { this._timer = _defaultTimerQueue.CreateTimer(_timerCallback, "DATA"); while (this._timer.HasExpired == false) { Thread.Sleep(5); } Assert.IsTrue(this._timer.HasExpired); }
private TimerThread.Timer SetTimeout(CancellationTokenSource cancellationTokenSource) { Contract.Requires(cancellationTokenSource != null); TimerThread.Timer timer = null; if (timeout != infiniteTimeout) { timer = TimerQueue.CreateTimer(timeoutCallback, cancellationTokenSource); } return(timer); }