开发者

Why won't my MessageQueue close properly?

How can I stop a synchronou开发者_JS百科s or asynchronous Receive from a MessageQueue in C#?

I find that if I haven't received any messages from the queue since I opened it, I can simply Close / Dispose the queue, and the Receive or EndReceive method will except, which is fine. However, if I've already successfully received a message from the queue, I can close and dispose the queue, but the pending or asynchronous receive will carry on regardless!

I've read elsewhere and found some suggestion that I should get EnableConnectionCache to false to ensure the message queue is closed when I ask, but it still seems to be ignore me regardless.


As binarycoder suggested, I have found that this is just a consequence of non-transactional queues. At least as far as MSMQ goes. A peek > receive pattern will solve the problem, but only if there is one reader. Otherwise, if you have the same issue you'll have to use transactional queues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜