private static void Process() { while (true) { if (shutdown) { return; } InstantMeterQueueItem item = null; lock (sync) { if (queue.Count > 0) { item = queue.Dequeue(); } } if (item != null) { DispatchItem(item); } else { pass.WaitOne(); } } }
public static void IncrementCounter(string resourceName, double incrementValue) { InstantMeterQueueItem item = new InstantMeterQueueItem { IncrementValue = incrementValue, ResourceName = resourceName, Time = DateTime.Now }; lock (sync) { queue.Enqueue(item); pass.Set(); } }
private static void DispatchItem(InstantMeterQueueItem item) { IncrementCounterPrivate(item.ResourceName, item.IncrementValue, item.Time); }