private async Task EnsureCountersAreUpToDate() { if (isUpdating) { return; } var now = DateTime.UtcNow; if ((now - lastRefreshTime) < updateInterval) { return; } isUpdating = true; try { var metricsGrain = GrainFactory.GetGrain <IManagementGrain>(0); var activationCountTask = metricsGrain.GetTotalActivationCount(); var simpleGrainStatsTask = metricsGrain.GetSimpleGrainStatistics(); var siloDetailsTask = siloDetailsProvider.GetSiloDetails(); await Task.WhenAll(activationCountTask, simpleGrainStatsTask, siloDetailsTask); RecalculateCounters(activationCountTask.Result, siloDetailsTask.Result, simpleGrainStatsTask.Result); lastRefreshTime = now; } finally { isUpdating = false; } }
private async Task Callback(object _) { var metricsGrain = GrainFactory.GetGrain <IManagementGrain>(0); var activationCountTask = metricsGrain.GetTotalActivationCount(); var simpleGrainStatsTask = metricsGrain.GetSimpleGrainStatistics(); var siloDetailsTask = siloDetailsProvider.GetSiloDetails(); await Task.WhenAll(activationCountTask, simpleGrainStatsTask, siloDetailsTask); RecalculateCounters(activationCountTask.Result, siloDetailsTask.Result, simpleGrainStatsTask.Result); }