예제 #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;
 }