コード例 #1
0
        public Task StartAsync()
        {
            _timer   = new SlidingTimer(OnTimer, _options.SlidingStep, _options.SlidingRadius, _logger);
            _aborted = new CancellationTokenSource();

            return(Task.CompletedTask);
        }
コード例 #2
0
 public void Dispose()
 {
     _aborted?.Dispose();
     _aborted = null;
     _timer?.Dispose();
     _timer = null;
 }
コード例 #3
0
        private async Task StopAsync(bool cancel, TimeSpan?delay)
        {
            _timer.Dispose();
            _timer = null;
            if (cancel)
            {
                if (delay > TimeSpan.Zero)
                {
                    _aborted.CancelAfter(delay.Value);
                }
                else
                {
                    _aborted.Cancel();
                }
            }

            await Task.WhenAll(_warps.Select(s => s.Task));

            await _transport.Flush();
        }