public void QueueJob(JobBase job) { lock (_jobs) { JobsDoneEvent.Reset(); _jobs.Enqueue(job); } _commandEvent.Set(); }
void ExecuteQueuedJobs() { for (; ;) { JobBase job; lock (_jobs) { if (_jobs.Count == 0) { JobsDoneEvent.Set(); return; } job = _jobs.Dequeue(); } job.Do(); } }