Solved

MSMQ Async Bug?

Posted on 2004-07-31
7
772 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

621 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