public void ProcessAsync(ActionFinishedDelegate onActionFinished) { MilSpace.Core.Logger.Info(string.Format("Action \"{0}\" with id {1} processing async", act.ActionId, this.ProcessId)); this.onActionFinished = onActionFinished; ProcessAsyncCaller caller = new ProcessAsyncCaller(this.Process); IAsyncResult result = caller.BeginInvoke(new AsyncCallback(worker_DoWork), null); }
private void worker_DoWork(IAsyncResult ar) { AsyncResult result = (AsyncResult)ar; ProcessAsyncCaller caller = (ProcessAsyncCaller)result.AsyncDelegate; IActionResult res = caller.EndInvoke(result); if (this.onActionFinished != null) { MilSpace.Core.Logger.Info(string.Format("Action \"{0}\" with id {1} processed async", act.ActionId, this.ProcessId)); MilSpace.Core.Logger.Info(string.Format("Action \"{0}\" calling callback function", act.ActionId)); this.onActionFinished(res); MilSpace.Core.Logger.Info(string.Format("Action \"{0}\" callback function performed", act.ActionId)); } // caller. }