private void Dispose(bool disposing) { if (disposing) { if (this.pauseTimer != null) { this.pauseTimer.Dispose(); this.pauseTimer = null; } } }
/// <summary> /// Initializes a new instance of the <see cref="MetricManager"/> class. /// </summary> /// <param name="client">Telemetry client to use to output aggregated metric data.</param> public MetricManager(TelemetryClient client) { this.telemetryClient = client ?? new TelemetryClient(); this.metricDictionary = new ConcurrentDictionary <Metric, SimpleMetricStatisticsAggregator>(); this.lastSnapshotStartDateTime = DateTimeOffset.UtcNow; this.snapshotTimer = new TaskTimerInternal() { Delay = GetWaitTime() }; this.snapshotTimer.Start(this.SnapshotAndReschedule); }
private static TaskTimerInternal InternalCreateAndStartTimer( int intervalInMilliseconds, Action action) { var timer = new TaskTimerInternal { Delay = TimeSpan.FromMilliseconds(intervalInMilliseconds), }; Func <Task> task = null; task = () => { timer.Start(task); action(); return(Task.FromResult <object>(null)); }; timer.Start(task); return(timer); }