/// <summary> /// Adds new work to the background worker's work queue. /// </summary> /// <param name="procedure"> /// Procedure the background worker will run. /// </param> /// <param name="argument1">First argument for procedure.</param> /// <param name="argument2">Second argument for procedure.</param> public void QueueWork(BackgroundWorkerProcedure procedure, object argument1, object argument2) { BackgroundWorkerQueueItem workItem = new BackgroundWorkerQueueItem(procedure, argument1, argument2); this.workQueueLock.WaitOne(); this.workQueue.Enqueue(workItem); this.workItemsQueued++; this.workQueueLock.ReleaseMutex(); this.workQueueHasNewWork.Set(); }