private static void Enqueue(LinkedList <Task> Queue, WaitCallback callback, object state) { itemsInQueue.Increment(); lock (lockAllQueue) { Queue.AddLast(new Task(callback, state)); } System.Threading.ThreadPool.QueueUserWorkItem(RunPriorityQueue); }
public void OnProcessSucceeded(object sender, Wammer.Station.HttpHandlerEventArgs evt) { try { avgTime.IncrementBy(evt.DurationInTicks); avgTimeBase.Increment(); } catch (Exception e) { Logger.Warn("Unable to write performance data: " + PerfCounter.AVG_TIME_PER_ATTACHMENT_UPLOAD, e); } }
public static void RunPriorityQueue(object nil) { try { Task task = Dequeue(); itemsInProgress.Increment(); task.Execute(null); } catch (Exception e) { Logger.Warn("Error while task execution", e); } finally { itemsInProgress.Decrement(); } }