public void ProcessJobs()
{
if (Thread.CurrentThread != _thread)
{
throw new InvalidOperationException("Unable to process jobs on a different thread.");
}
lock (_queue)
{
// Process all jobs
while (_queue.Count > 0)
{
var action = _queue.Dequeue();
lock (action)
{
action(); //
ThreadMonitor.PulseAll(action);
}
}
}
}