Пример #1
0
 public async Task InvokeAsync()
 {
     try
     {
         ClaimEventToken token = new ClaimEventToken();
         foreach (var target in _invocationList)
         {
             if (target.BlockingEventWithClaimToken != null)
             {
                 target.BlockingEventWithClaimToken(ref token);
                 if (token.Claimed)
                 {
                     return;
                 }
             }
             await target.Event();
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine("Exception when invoking an event asynchronously:");
         Debug.WriteLine(e.ToString());
         throw;
     }
 }
Пример #2
0
 public void Invoke()
 {
     try
     {
         ClaimEventToken token = new ClaimEventToken();
         foreach (var target in _invocationList)
         {
             if (target.BlockingEventWithClaimToken != null)
             {
                 target.BlockingEventWithClaimToken(ref token);
                 if (token.Claimed)
                 {
                     return;
                 }
             }
             if (target.BlockingEvent != null)
             {
                 target.BlockingEvent();
             }
             else
             {
                 target.Event();
             }
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine("Exception when invoking an event:");
         Debug.WriteLine(e.ToString());
         throw;
     }
 }
Пример #3
0
 private void onEventDontClaim(MockEventArgs e, ref ClaimEventToken token)
 {
     Assert.AreEqual(x, e.X);
     syncEvents++;
 }