private void MaybeProcessNextWorkflow() { lock (this.workflowQueue) { if ((this.currentWorkflow != null) && (this.currentWorkflow.IsComplete == false)) { return; } if (this.workflowQueue.Count > 0) { this.currentWorkflow = this.workflowQueue.Dequeue(); this.currentWorkflow.Complete += OnWorkflowComplete; ThreadPool.QueueUserWorkItem(new WaitCallback(this.currentWorkflow.Begin)); } } }
private void EnqueueWorkflow(WorkflowBase workflow) { lock (this.workflowQueue) { // If we are unloading the camera, it's safe to clear the workflow queue // if (workflow is UnloadCameraWorkflow) { this.workflowQueue.Clear(); } this.workflowQueue.Enqueue(workflow); } MaybeProcessNextWorkflow(); }