private void ReportCompletion(IAsyncResult asyncResult) { AsyncResult ar = (AsyncResult)asyncResult; DoWorkEventHandler handler = (DoWorkEventHandler)ar.AsyncDelegate; DoWorkEventArgs args = (DoWorkEventArgs)ar.AsyncState; object result = null; Exception error = null; try { handler.EndInvoke(asyncResult); result = args.Result; } catch (Exception exception) { error = exception; } if (RunWorkerCompleted != null) { InvokeDelegate(RunWorkerCompleted.GetInvocationList(), new object[] { this, new RunWorkerCompletedEventArgs(result, error, args.Cancel) }); } }
/// <summary> /// Called when [run worker completed]. /// </summary> /// <param name="ar">The ar.</param> private void OnRunWorkerCompleted(IAsyncResult ar) { DoWorkEventArgs args = (DoWorkEventArgs)ar.AsyncState; try { DoWorkEventHandler doWorkDelegate = (DoWorkEventHandler)((AsyncResult)ar).AsyncDelegate; doWorkDelegate.EndInvoke(ar); if (this.RunWorkerCompleted != null) { this.RunWorkerCompleted(this, new RunWorkerCompletedEventArgs(args.Result, null, args.Cancel)); } } catch (Exception ex) { if (this.RunWorkerCompleted != null) { this.RunWorkerCompleted(this, new RunWorkerCompletedEventArgs(args.Result, ex, args.Cancel)); } } _count--; }
private void ReportCompletion(IAsyncResult asyncResult) { System.Runtime.Remoting.Messaging.AsyncResult ar = asyncResult as System.Runtime.Remoting.Messaging.AsyncResult; DoWorkEventHandler del = ar.AsyncDelegate as DoWorkEventHandler; DoWorkEventArgsBw doWorkArgs = (DoWorkEventArgsBw)ar.AsyncState; object result = null; Exception error = null; try { del.EndInvoke(asyncResult); result = doWorkArgs.Result; } catch (Exception exception) { error = exception; } RunWorkerCompletedEventArgsBw completedArgs = new RunWorkerCompletedEventArgsBw(result, error, doWorkArgs.Cancel); OnRunWorkerCompleted(completedArgs); }
private void reportCompletion(IAsyncResult pAsyncResult) { AsyncResult _asyncResult = (AsyncResult)pAsyncResult; DoWorkEventHandler _del = (DoWorkEventHandler)_asyncResult.AsyncDelegate; WorkerEventArgs _doWorkArgs = (WorkerEventArgs)pAsyncResult.AsyncState; object _result = null; Exception _error = null; try { _del.EndInvoke(pAsyncResult); _result = _doWorkArgs.Result; } catch (Exception _ex) { _error = _ex; } WorkCompletedEventArgs _completedArgs = new WorkCompletedEventArgs(_result, _error, _doWorkArgs.Cancel); onWorkerCompleted(_completedArgs); }
void ReportCompletion(IAsyncResult asyncResult) { AsyncResult ar = (AsyncResult)asyncResult; DoWorkEventHandler del = (DoWorkEventHandler)ar.AsyncDelegate; DoWorkEventArgs doWorkArgs = (DoWorkEventArgs)asyncResult.AsyncState; object result = null; Exception error = null; try { del.EndInvoke(asyncResult); result = doWorkArgs.Result; } catch (Exception exception) { error = exception; } WorkCompletedEventArgs completedArgs = new WorkCompletedEventArgs(result, error, doWorkArgs.Cancel); OnWorkerCompleted(completedArgs); }