protected override void PerformMainLoopService() { if (sampleIntervalTimer.Started != BaseState.IsOnline) { if (BaseState.IsOnline) { sampleIntervalTimer.Reset(triggerImmediately: true); } else { sampleIntervalTimer.Stop(); } } if (sampleIntervalTimer.IsTriggered) { h1.Clear(); QpcTimeStamp now = QpcTimeStamp.Now; for (int idx = 0; idx < h1SampleSize; idx++) // this loop is fast enough to not need to check for HasStopBeenRequested { QpcTimeStamp start = now; System.Threading.Thread.Sleep(1); QpcTimeStamp end = now = QpcTimeStamp.Now; h1.Add((end - start).TotalSeconds); } System.Threading.Thread.Sleep(10); h10.Clear(); now = QpcTimeStamp.Now; for (int idx = 0; idx < h10SampleSize && !HasStopBeenRequested && actionQ.IsEmpty; idx++) { QpcTimeStamp start = now; System.Threading.Thread.Sleep(10); QpcTimeStamp end = now = QpcTimeStamp.Now; h10.Add((end - start).TotalSeconds); } System.Threading.Thread.Sleep(10); h30.Clear(); now = QpcTimeStamp.Now; for (int idx = 0; idx < h100SampleSize && !HasStopBeenRequested && actionQ.IsEmpty; idx++) { QpcTimeStamp start = now; System.Threading.Thread.Sleep(30); QpcTimeStamp end = now = QpcTimeStamp.Now; h30.Add((end - start).TotalSeconds); } h1Grp.UpdateGroupItems(); h10Grp.UpdateGroupItems(); h30Grp.UpdateGroupItems(); ah1.Add(h1); ah10.Add(h10); ah30.Add(h30); bool aggregationIntervalTimerTriggered = aggregationIntervalTimer.IsTriggered; if (aggregationIntervalTimerTriggered) { ah1Grp.UpdateGroupItems(); ah10Grp.UpdateGroupItems(); ah30Grp.UpdateGroupItems(); Log.Info.Emit("AH10: {0}", ah10.ToString(Histogram.TSInclude.BaseWithMedEst | Histogram.TSInclude.BinCountArray)); } mdrfWriter.RecordGroups(); if (aggregationIntervalTimerTriggered) { ah1.Clear(); ah10.Clear(); ah30.Clear(); } } }