Пример #1
0
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            Trace.WriteLine("Starting Pi estimation.");

            Estimate next = Estimate.PI(null);

            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();

                next = Estimate.PI(next);

                ServiceEventSource.Current.ServiceMessage(this, next.ToString());

                await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
            }
        }