Solved

MSMQ Async Bug?

Posted on 2004-07-31
7
767 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

825 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