public IAsyncResult BeginInvoke(Delegate method, object[] args) { var result = new SimpleAsyncResult(); ThreadPool.QueueUserWorkItem((object state) => { result.AsyncWaitHandle = new ManualResetEvent(false); try { result.AsyncState = Invoke(method, args); } catch (Exception exception) { result.Exception = exception; } result.IsCompleted = true; }); return result; }
public IAsyncResult BeginInvoke(Delegate method, object[] args) { var result = new SimpleAsyncResult(); ThreadPool.QueueUserWorkItem((object state) => { result.AsyncWaitHandle = new ManualResetEvent(false); try { result.AsyncState = Invoke(method, args); } catch (Exception exception) { result.Exception = exception; } result.IsCompleted = true; }); return(result); }