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; } }
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; } }
private void onEventDontClaim(MockEventArgs e, ref ClaimEventToken token) { Assert.AreEqual(x, e.X); syncEvents++; }