J
Jeff Johnson
I guess simply waiting on an asynchronous Receive from a message queue is
not enough to keep a Windows service alive? I've written a service whose
only purpose is to process a message queue. The OnStart method looks like
this:
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
_executionQueue = new
MessageQueue(Properties.Settings.Default.ExecutionQueuePath);
_executionQueue.ReceiveCompleted += new
ReceiveCompletedEventHandler(ReceiveCompletedHandler);
_executionQueue.BeginReceive();
}
I thought this would start a thread to wait on the I/O event and this would
keep the service going, but as soon as I start the service I get the error
telling me it started and then stopped ("no work to do" etc.). Should I
throw in a dummy timer? That seems like a waste of resources to me. Also, a
newsgroup search turned up a suggestion to run everything from a class and
in a "while (_keepRunningFlag) { ... }" loop. Ideas?
not enough to keep a Windows service alive? I've written a service whose
only purpose is to process a message queue. The OnStart method looks like
this:
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
_executionQueue = new
MessageQueue(Properties.Settings.Default.ExecutionQueuePath);
_executionQueue.ReceiveCompleted += new
ReceiveCompletedEventHandler(ReceiveCompletedHandler);
_executionQueue.BeginReceive();
}
I thought this would start a thread to wait on the I/O event and this would
keep the service going, but as soon as I start the service I get the error
telling me it started and then stopped ("no work to do" etc.). Should I
throw in a dummy timer? That seems like a waste of resources to me. Also, a
newsgroup search turned up a suggestion to run everything from a class and
in a "while (_keepRunningFlag) { ... }" loop. Ideas?