public void RunWorkerAsync( object argument ) { mCancelPending = false; if( DoWork != null ) { DoWorkEventArgsBw args = new DoWorkEventArgsBw( argument ); AsyncCallback callback = new AsyncCallback( ReportCompletion ); DoWork.BeginInvoke( this, args, callback, args ); } }
public void RunWorkerAsync(object argument) { mCancelPending = false; if (DoWork != null) { DoWorkEventArgsBw args = new DoWorkEventArgsBw(argument); AsyncCallback callback = new AsyncCallback(ReportCompletion); DoWork.BeginInvoke(this, args, callback, args); } }
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); }