I have a bit of code that (vb.net VS2008 SP1) that connects to a Queue in MSMQ and creates an event handler using the asynchronous BeginPeek method.
When an item appears in the queue, the MyPeekCompleted event doesn't get called.
If I run the code in a Win Forms app it works fine
, if I run the same code within a Windows service the MyPeekCompleted event never gets called.
Any ideas why it fails when running as a service?
Public Class MyClass
Public q As MessageQueue = Nothing
public sub New()
q = New MessageQueue(".\Private$\MyQueue")
AddHandler q.PeekCompleted, AddressOf MyPeekCompleted
Public Sub MyPeekCompleted(ByVal [source] As [Object], _
ByVal asyncResult As PeekCompletedEventArgs)
' **** THIS NEVER GETS CALLED WHEN RUNNING AS A WINDOWS SERVICE ****