/// <summary> /// Gets the value from the synchronous method call by inspecting the return value. /// </summary> /// <param name="result">Original IAsyncResult interface from BeginInvoke</param> /// <returns>Returning object</returns> public object EndInvoke(IAsyncResult result) { AsynchCallResult asynchResult = (AsynchCallResult)result; asynchResult.AsyncWaitHandle.WaitOne(); return(asynchResult.ReturnValue); }
/// <summary> /// Takes the delegate to the synchronous method, and queues it up for execution on a /// thread pool. The thread pool calls DoInvoke to execute. /// </summary> /// <param name="method">Method to call</param> /// <param name="args">Arguments for method</param> /// <returns>IAsyncResult interface</returns> public IAsyncResult BeginInvoke(Delegate method, object[] args) { AsynchCallResult result = new AsynchCallResult(method, args, asynchCallback_, state_, this); ThreadPool.QueueUserWorkItem(new WaitCallback(result.DoInvoke)); return((IAsyncResult)result); }
/// <summary> /// This returns the result of the asynchronous method. /// </summary> /// <param name="ar">Returned IAsyncResult from the Invoke</param> /// <returns>System.Object result</returns> static public object ProcessEndInvoke(IAsyncResult ar) { AsynchCallResult acr = (AsynchCallResult)ar; return(acr.AsynchCall.EndInvoke(ar)); }