internal override void ExecuteSync(SynchronizedOperation synchronizedOperation) { lock (m_syncRoot) { synchronizedOperation(); } }
// This method is called by the synchronized operation to // ensure that items are never processed in parallel. private void Execute() { try { ProcessingThread = Thread.CurrentThread; while (true) { if (!Queue.TryDequeue(out QueuedTask queuedTask)) { break; } Task task = queuedTask.Task; Scheduler scheduler = queuedTask.Scheduler; if (scheduler.TryExecuteTask(task)) { break; } } } finally { ProcessingThread = null; if (!Queue.IsEmpty) { SynchronizedOperation.RunAsync(); } } }
// This method is called by the synchronized operation to // ensure that items are never processed in parallel. private void Execute() { try { ProcessingThread = Thread.CurrentThread; // This while loop ensures that this method does its // best to execute a task before exiting, thus reducing // unnecessary iterations of the async loop while (true) { if (!Queue.TryDequeue(out Task task)) { return; } // A task could be cancelled or inlined after it was queued, // causing this to return false without doing anything if (TryExecuteTask(task)) { break; } } } finally { ProcessingThread = null; if (!Queue.IsEmpty) { SynchronizedOperation.RunAsync(); } } }
public override void ExecuteSync(SynchronizedOperation synchronizedOperation) { lock (MetafileGraphics.m_syncRoot) { synchronizedOperation(); } }
private void QueueTask(Task task, Scheduler scheduler) { int priority = scheduler.Priority; QueuedTask queuedTask = new QueuedTask(task, scheduler); Queue.Enqueue(queuedTask, priority); SynchronizedOperation.RunAsync(); }
public virtual void ExecuteSync(SynchronizedOperation synchronizedOperation) { synchronizedOperation(); }
/// <summary> /// Queues a <see cref="Task"/> to the scheduler. /// </summary> /// <param name="task">The <see cref="Task"/> to be queued.</param> protected override void QueueTask(Task task) { Queue.Enqueue(task); SynchronizedOperation.RunAsync(); }
internal virtual void ExecuteSync(SynchronizedOperation synchronizedOperation) { synchronizedOperation(); }