/// <summary> /// Initializes a new instance of the BackgroundWorkerQueueItem class. /// </summary> /// <param name="procedure">Procedure to run.</param> /// <param name="argument1">First argument for procedure.</param> /// <param name="argument2">Second argument for procedure.</param> public BackgroundWorkerQueueItem( BackgroundWorkerProcedure procedure, object argument1, object argument2) { this.procedure = procedure; this.argument1 = argument1; this.argument2 = argument2; }
/// <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(); }
/// <summary> /// Initializes a new instance of the BackgroundWorkerQueueItem class. /// </summary> /// <param name="procedure">Procedure to run.</param> /// <param name="argument1">First argument for procedure.</param> /// <param name="argument2">Second argument for procedure.</param> public BackgroundWorkerQueueItem( BackgroundWorkerProcedure procedure, object argument1, object argument2) { this.procedure = procedure; this.argument1 = argument1; this.argument2 = argument2; }
/// <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(); }