Created
October 28, 2014 13:13
-
-
Save zapthedingbat/914623c6f0aebacdd526 to your computer and use it in GitHub Desktop.
Timeout calls to IBus.Send().Register()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: There is a bug in NServiceBus where registered callbacks that are not invoked remain in a static dictionary. | |
var asyncResult = _bus.Send(message).Register(ar => { }, null); | |
if (!asyncResult.AsyncWaitHandle.WaitOne(_timeout)) | |
{ | |
// Signal the async result so callback threads don't remain blocked | |
((EventWaitHandle)asyncResult.AsyncWaitHandle).Set(); | |
throw new OperationCanceledException(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment