/// <summary> /// Calculates an approximate value of Pi. /// Note that this version of the algorithm is async. /// </summary> public async Task CalculateAsync(PiCalcData data, CancellationToken token) { // Main loop in algorithm (started as a new Task, is cancellable). // await Task.Run(() => Calculate(data, () => !token.IsCancellationRequested), token); }
/// <summary> /// Calculates an approximate value of Pi. /// Note that this version does NOT use async. /// </summary> public void CalculateSync(PiCalcData data, int iterationsToPerform) { // Main loop in algorithm // Calculate(data, () => _iterations < iterationsToPerform); }