private ProcessWorkerResult ProcessWorker(object user) { ProcessWorkerResult result = new ProcessWorkerResult(); result.Canceled = false; result.Error = null; try { if (ProcessStarted != null) { AsyncProcessStartedEventArgs arguments = new AsyncProcessStartedEventArgs(); arguments.User = user; ProcessStarted(this, arguments); result.Canceled = arguments.Cancel; result.Result = arguments.Result; } } catch (Exception ex) { result.Error = ex; } return(result); }
private void ProcessCallback(IAsyncResult ar) { ProcessDelegate del = (ProcessDelegate)ar.AsyncState; ProcessWorkerResult result = del.EndInvoke(ar); if (ProcessFinished != null) { ProcessFinished(this, new AsyncProcessFinishedEventArgs() { Canceled = result.Canceled, Error = result.Error, Result = result.Result }); } }