private void load(ScorePerformanceCache performanceCache) { if (score.PP.HasValue) { setPerformanceValue(score.PP.Value); } else { performanceCache.CalculatePerformanceAsync(score, cancellationTokenSource.Token) .ContinueWith(t => Schedule(() => setPerformanceValue(t.GetResultSafely()?.Total)), cancellationTokenSource.Token); } }
public async Task <PerformanceBreakdown> CalculateAsync(ScoreInfo score, CancellationToken cancellationToken = default) { PerformanceAttributes[] performanceArray = await Task.WhenAll( // compute actual performance performanceCache.CalculatePerformanceAsync(score, cancellationToken), // compute performance for perfect play getPerfectPerformance(score, cancellationToken) ).ConfigureAwait(false); return(new PerformanceBreakdown { Performance = performanceArray[0], PerfectPerformance = performanceArray[1] }); }