Solved

MSMQ Async Bug?

Posted on 2004-07-31
7
768 Views
Last Modified: 2012-06-21
I have an application that is using MSMQ.

I have written an event handler to handle async message receiving.

it looks something like this :

Private Sub handler(ByVal objt00 As Object, ByVal objt01 As ReceiveCompletedEventArgs)
...
...
' SHOULD BE TRUE IF THERE IS A MESSAGE, FALSE IF TIMEOUT EXPIRED
If objt01.AsyncResult.IsCompleted Then
 ' process message
Else
 ' look to see if shutdown waithandle has occured
 ' if not, resume listening with BeginReceive(TimeSpan)
End If
...
...
End Sub

I initially call BeginReceive(TimeSpan) in a different function

The problem I have is that even if the timeout expires the AsyncResult.IsCompleted flag is true - and there are no messages to process
Has anyone else had this problem or know what I'm doing wrong?

Thanks.
0
Comment
Question by:BJohnston
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 

Author Comment

by:BJohnston
ID: 11685576
As an addendum to my previous post, this is the MSDN documentation from which I am drawing my conclusions as to how the event handler should function. . .

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmessagingmessagequeueclassbeginreceivetopic2.asp


note especially the portion that reads...

This overload specifies a time-out. If the interval specified by the timeout parameter expires, this component raises the ReceiveCompleted event, but the IsCompleted property of the operation's associated IAsyncResult is false. Because no message exists, a subsequent call to EndReceive will throw an exception.



I have temporarily patched this by simply catching the exception generated by the errant call to EndReceive and started BeginReceive again. . . sigh
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11688722
intresting, the documentation agrees ... what if anything is the state of the result object at this point.
0
 

Author Comment

by:BJohnston
ID: 11711154
Having talked with a Microsoft technical representative i have been informed that there is a documentation error and that regardless of what triggers the callback (either a Message arrival or a timeout) the AsyncResult.IsCompleted flag will be true.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11711163
documentation error ... hmm ... sounds more like a functionality flaw to me :)
0
 

Author Comment

by:BJohnston
ID: 11913425
Please refund points as there was no answer to be had.  Thank you.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11946782
PAQed, with points refunded (125)

modulo
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question