示例#1
0
 public void BeginMessageLoop()
 {
     while (!done)
     {
         Tuple <SendOrPostCallback, object> task = null;
         lock (items)
         {
             if (items.Count > 0)
             {
                 task = items.Dequeue();
             }
         }
         if (task != null)
         {
             task.Item1(task.Item2);
             if (InnerException != null) // the method threw an exeption
             {
                 throw new AggregateException("AsyncHelpers.Run method threw an exception.", InnerException);
             }
         }
         else
         {
             workItemsWaiting.WaitOne();
         }
     }
 }