private void processCommand_StatusAvailable(object sender, TaskCommandStatusEventArgs e) { TaskCommandStatus status = e.Status; if (status == null) { throw new InvalidOperationException("status"); } if (JobStatusAvailable == null) { jobStatusQueue.Enqueue(status); // TODO: what if too much status? } else { jobStatusQueue.Enqueue(status); TaskCommandStatus queued; while ((!jobStatusQueue.IsEmpty) && jobStatusQueue.TryDequeue(out queued)) { JobStatusAvailable(this, new JobStatusEventArgs(status)); } } }