Пример #1
0
            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
                    );
            }
Пример #2
0
            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;
            }