protected virtual void OnDoWork(QueuedWorkerDoWorkEventArgs e) { if (this.queuedWorkerDoWorkEventHandler_0 != null) { this.queuedWorkerDoWorkEventHandler_0(this, e); } }
/// <summary> /// Raises the DoWork event. /// </summary> /// <param name="e">A <see cref="QueuedWorkerDoWorkEventArgs"/> that contains event data.</param> protected virtual void OnDoWork(QueuedWorkerDoWorkEventArgs e) { if (DoWork != null) { DoWork(this, e); } }
private void method_9() { // This item is obfuscated and can not be translated. object obj2; Label_0001: if (this.method_7()) { return; } lock ((obj2 = this.object_0)) { if (this.method_0()) { Monitor.Wait(this.object_0); } } bool flag2 = true; while (!flag2) { if (0 == 0) { goto Label_0001; } AsyncOperation operation = null; object key = null; int priority = 0; lock ((obj2 = this.object_0)) { Class7 <AsyncOperation, int> class2 = this.method_2(); operation = class2.method_0(); priority = class2.method_1(); if (operation != null) { key = operation.UserSuppliedState; } if ((key != null) && this.dictionary_0.ContainsKey(key)) { key = null; } } if (key != null) { Exception error = null; QueuedWorkerDoWorkEventArgs e = new QueuedWorkerDoWorkEventArgs(key, priority); try { this.OnDoWork(e); } catch (Exception exception2) { error = exception2; } QueuedWorkerCompletedEventArgs arg = new QueuedWorkerCompletedEventArgs(key, e.Result, priority, error, e.Cancel); if (!this.method_7()) { operation.PostOperationCompleted(this.sendOrPostCallback_0, arg); } } else if (operation != null) { operation.OperationCompleted(); } lock ((obj2 = this.object_0)) { flag2 = !this.method_0(); continue; } break; } goto Label_004E; }
/// <summary> /// Used by the worker thread to process items. /// </summary> private void Run() { while (!Stopping) { lock (lockObject) { // Wait until we have pending work items if (IsWorkQueueEmpty()) { Monitor.Wait(lockObject); } } // Loop until we exhaust the queue bool queueFull = true; while (queueFull && !Stopping) { // Get an item from the queue AsyncOperation asyncOp = null; object request = null; int priority = 0; lock (lockObject) { // Check queues Tuple <AsyncOperation, int> work = GetWork(); asyncOp = work.Item1; priority = work.Item2; if (asyncOp != null) { request = asyncOp.UserSuppliedState; } // Check if the item was removed if (request != null && cancelledItems.ContainsKey(request)) { request = null; } } if (request != null) { Exception error = null; // Start the work QueuedWorkerDoWorkEventArgs arg = new QueuedWorkerDoWorkEventArgs(request, priority); try { // Raise the do work event OnDoWork(arg); } catch (Exception e) { error = e; } // Raise the work complete event QueuedWorkerCompletedEventArgs arg2 = new QueuedWorkerCompletedEventArgs(request, arg.Result, priority, error, arg.Cancel); if (!Stopping) { asyncOp.PostOperationCompleted(workCompletedCallback, arg2); } } else if (asyncOp != null) { asyncOp.OperationCompleted(); } // Check if the cache is exhausted lock (lockObject) { queueFull = !IsWorkQueueEmpty(); } } } }