public WatcherTimerPair(IWebWatcher watcher, Action <WatcherTimerPair> action) { #if DEBUG id = i++; Log.Verbose($"New WatcherTimerPair created, ID: {id}"); #endif Watcher = watcher; Action = action; Name = watcher.Name; Timer = new Task( async() => { while (!Cancel) { await Task.Delay(watcher.Interval); if (!Pause) { Action(this); } } }, CancellationToken.None, TaskCreationOptions.LongRunning ); }
public WatcherTimerPair(IWebWatcher watcher) { #if DEBUG id = i++; Log.Verbose($"New WatcherTimerPair created, ID: {id}"); #endif Watcher = watcher; Timer = new(watcher.Interval.TotalMilliseconds); Timer.AutoReset = true; }