public static async Task WaitThenDisplayMessageAsync(TimeSpan interval, string message, Func <Task> waitOperation) { UIWaitDialog waitDialog = null; var bgTimer = new TimerMonitor(TimerMonitor.TimerFrequency.Once) { Interval = new TimeSpan(0, 0, RConstants.CopyDialogWaitTime), TimeOutEvent = async delegate() { waitDialog = new UIWaitDialog() { ContentStr = message }; await waitDialog.ShowAsync(); } }; bgTimer.Launch(); await waitOperation(); if (bgTimer.HasStop && waitDialog != null) { waitDialog.Hide(); bgTimer.Terminate(); } }
void RunTest(long delay, long period) { TimerMonitor monitor = new TimerMonitor(); int expected = 10; TestEventHandler handler = new TestEventHandler(monitor, expected); IStage stage = new TimerStage(handler, delay, period); monitor.Mwait(); Assert.Equal(expected, handler.GetCount()); }
internal static IMonitor CreateMonitor(MonitorType type, Options options, Action <string> outputFunction, CancellationToken token) { IMonitor monitor; switch (type) { case MonitorType.Timer: monitor = new TimerMonitor(options, outputFunction, token); break; case MonitorType.FileSystemWatcher: monitor = new DirectoryMonitor(options, outputFunction, token); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return(monitor); }
public TestEventHandler(TimerMonitor monitor, long expected) { _count = 0; _monitor = monitor; _expected = expected; }