public ThreadProcessor ( ConcurrentAsyncQueue <T> queue , EventWaitHandle wait ) { Break = false; Waiter = wait; Sender = queue; QueuePerformanceCountersContainer qpcc = Sender .PerformanceCountersContainer; _timerCounters = new WriteableTuple < bool , Stopwatch , PerformanceCounter , PerformanceCounter >[] { WriteableTuple .Create < bool , Stopwatch , PerformanceCounter , PerformanceCounter > ( false , null , qpcc .QueuedWaitAverageTimerPerformanceCounter , qpcc .QueuedWaitAverageBasePerformanceCounter ) , WriteableTuple .Create < bool , Stopwatch , PerformanceCounter , PerformanceCounter > ( true , null , qpcc .DequeueProcessedAverageTimerPerformanceCounter , qpcc .DequeueProcessedAverageBasePerformanceCounter ) }; }
public void AttachPerformanceCountersCategoryInstance ( string performanceCountersCategoryNamePrefix , string performanceCountersCategoryInstanceNamePrefix , Func <bool> onGetEnabledCountPerformanceProcessFunc = null , PerformanceCounterInstanceLifetime performanceCounterInstanceLifetime = PerformanceCounterInstanceLifetime.Process ) { var process = Process.GetCurrentProcess(); var processName = process.ProcessName; var instanceNamePrefix = string .Format ( "{0}-{1}" , processName , performanceCountersCategoryInstanceNamePrefix ); instanceNamePrefix = performanceCountersCategoryInstanceNamePrefix; var suffix = "-Queue"; _performanceCountersCategoryNameForQueueProcess = performanceCountersCategoryNamePrefix + suffix; _performanceCountersCategoryInstanceNameForQueueProcess = instanceNamePrefix + suffix; var qpcc = _queuePerformanceCountersContainer; qpcc .AttachPerformanceCountersToMembers ( _performanceCountersCategoryNameForQueueProcess , _performanceCountersCategoryInstanceNameForQueueProcess , performanceCounterInstanceLifetime ); qpcc .RegisterCountersUsage(); suffix = "-BatchProcess"; _performanceCountersCategoryNameForBatchProcess = performanceCountersCategoryNamePrefix + suffix; _performanceCountersCategoryInstanceNameForBatchProcess = instanceNamePrefix + suffix; CommonPerformanceCountersContainer container = null; EasyPerformanceCountersHelper <CommonPerformanceCountersContainer> .AttachPerformanceCountersCategoryInstance ( _performanceCountersCategoryNameForBatchProcess , _performanceCountersCategoryInstanceNameForBatchProcess , out container , performanceCounterInstanceLifetime ); if (_timerCounters == null) { _timerCounters = new WriteableTuple < bool , Stopwatch , PerformanceCounter , PerformanceCounter >[] { WriteableTuple .Create < bool , Stopwatch , PerformanceCounter , PerformanceCounter > ( false , null , _queuePerformanceCountersContainer .QueuedWaitAverageTimerPerformanceCounter , _queuePerformanceCountersContainer .QueuedWaitAverageBasePerformanceCounter ) , WriteableTuple .Create < bool , Stopwatch , PerformanceCounter , PerformanceCounter > ( true , null , _queuePerformanceCountersContainer .DequeueProcessedAverageTimerPerformanceCounter , _queuePerformanceCountersContainer .DequeueProcessedAverageBasePerformanceCounter ) }; } _isAttachedPerformanceCounters = true; OnGetEnabledCountPerformanceProcessFunc = onGetEnabledCountPerformanceProcessFunc; }