Пример #1
0
 public static void Execute(AsyncCall call, AsyncResult result)
 {
     try
     {
         result.Return = call();
     }
     catch (Exception e)
     {
         result.LastException = e;
         result.Return = null;
     }
     finally
     {
         result.SignalWaitHandle();
         if (result.Callback != null)
         {
             result.Callback(result);
         }
     }
 }
Пример #2
0
 public static IAsyncResult BeginOperation(AsyncCall call, AsyncCallback callback, object state)
 {
     AsyncResult result = new AsyncResult(callback, state);
     new Thread(() => Execute(call, result)).Start();
     return result;
 }