private void InitializeClicked(object sender, RoutedEventArgs e) { if (PerformanceCounterCategory.Exists(CategoryName)) { PerformanceCounterCategory.Delete(CategoryName); } if (!PerformanceCounterCategory.Exists(CategoryName)) { CounterCreationDataCollection creationDataCollection = new CounterCreationDataCollection(); CounterCreationData ctrCreationData = new CounterCreationData(); ctrCreationData.CounterType = PerformanceCounterType.RateOfCountsPerSecond32; ctrCreationData.CounterName = SpeedCounterName; creationDataCollection.Add(ctrCreationData); CounterCreationData ctrCreationData2 = new CounterCreationData(); ctrCreationData2.CounterType = PerformanceCounterType.RateOfCountsPerSecond64; ctrCreationData2.CounterName = SpeedBytesCounterName; creationDataCollection.Add(ctrCreationData2); PerformanceCounterCategory.Create(CategoryName, "Sample Custom category", PerformanceCounterCategoryType.MultiInstance, creationDataCollection); } currentContainer = new CountersContainer() { BytesPerSecCounter = SetupCounter(CategoryName, SpeedCounterName, "Task " + currentTask), ItemsPerSecCounter = SetupCounter(CategoryName, SpeedBytesCounterName, "Task " + currentTask) }; }
private void InitializeClicked(object sender, RoutedEventArgs e) { if (PerformanceCounterCategory.Exists(CategoryName)) { PerformanceCounterCategory.Delete(CategoryName); } if (!PerformanceCounterCategory.Exists(CategoryName)) { CounterCreationDataCollection creationDataCollection = new CounterCreationDataCollection(); CounterCreationData ctrCreationData = new CounterCreationData(); ctrCreationData.CounterType = PerformanceCounterType.RateOfCountsPerSecond32; ctrCreationData.CounterName = SpeedCounterName; creationDataCollection.Add(ctrCreationData); CounterCreationData ctrCreationData2 = new CounterCreationData(); ctrCreationData2.CounterType = PerformanceCounterType.RateOfCountsPerSecond64; ctrCreationData2.CounterName = SpeedBytesCounterName; creationDataCollection.Add(ctrCreationData2); PerformanceCounterCategory.Create(CategoryName, "Sample Custom category", PerformanceCounterCategoryType.MultiInstance, creationDataCollection); } currentContainer = new CountersContainer() { BytesPerSecCounter = SetupCounter(CategoryName, SpeedCounterName, "Task " + currentTask), ItemsPerSecCounter = SetupCounter(CategoryName, SpeedBytesCounterName, "Task " + currentTask) }; }
private void AddInstanceClicked(object sender, RoutedEventArgs e) { maxItem++; currentContainer = new CountersContainer() { BytesPerSecCounter = SetupCounter(CategoryName, SpeedCounterName, "Task " + currentTask), ItemsPerSecCounter = SetupCounter(CategoryName, SpeedBytesCounterName, "Task " + currentTask) }; comboBoxInstance.Items.Add(maxItem); }
private void AddInstanceClicked(object sender, RoutedEventArgs e) { maxItem++; currentContainer = new CountersContainer() { BytesPerSecCounter = SetupCounter(CategoryName, SpeedCounterName, "Task " + currentTask), ItemsPerSecCounter = SetupCounter(CategoryName, SpeedBytesCounterName, "Task " + currentTask) }; comboBoxInstance.Items.Add(maxItem); }
private static void DoProcessing(object arg) { CountersContainer ctr = arg as CountersContainer; Random r = new Random(DateTime.Now.Millisecond); ctr.ItemsPerSecCounter.NextSample(); ctr.BytesPerSecCounter.NextSample(); while (true) { Thread.Sleep(r.Next(20, 300)); int messageSize = r.Next(512, 1024 * 500); ctr.ItemsPerSecCounter.Increment(); ctr.BytesPerSecCounter.IncrementBy(messageSize); } }