コード例 #1
0
ファイル: PeriodicReporter.cs プロジェクト: lulzzz/Jasiri
 public PeriodicReporter(ISender sender, FlushOptions flushOptions)
 {
     this.sender   = sender;
     batch         = new Buffer <Span>(flushOptions.MaxBufferSize);
     periodicAsync = new PeriodicAsync(FlushAsync, flushOptions.FlushInterval, flushOptions.CancellationToken);
     periodicAsync.Start(this);
 }
コード例 #2
0
        public async Task LoopInvokesActionWithSuppliedArg()
        {
            var tcs  = new TaskCompletionSource <object>();
            var cts  = new CancellationTokenSource();
            var loop = new PeriodicAsync((obj, ct) =>
            {
                if (obj is TaskCompletionSource <object> t)
                {
                    t.TrySetResult(null);
                    cts.Cancel();
                }
                return(Task.CompletedTask);
            }, TimeSpan.FromMilliseconds(100), cts.Token);

            loop.Start(tcs);
            await tcs.Task;
        }