M
Massimo
I'm writing a .NET (2.0) application than needs to receive messages from a
message queue and do some processing on them; the application is
multithreaded, and each thread runs in a loop receving a message, processing
it and so on; the loop is controlled by a flag, if this flag becomes to true
the thread exits.
To stop the application, the controller thread sets the flag to true and
calls Thread.Interrupt() on each thread... but this doesn't seem to stop the
thread if it's blocked on a MessageQueue.Receive() operation.
Why is this?
And how can I solve this problem?
Someone suggested using a two-part loop, having the thread sleep for a while
and then check the message queue with a short timeout; this way, the thread
can be interrupted. But this seems a lot inefficient to me.
Any ideas?
Thanks
Massimo
message queue and do some processing on them; the application is
multithreaded, and each thread runs in a loop receving a message, processing
it and so on; the loop is controlled by a flag, if this flag becomes to true
the thread exits.
To stop the application, the controller thread sets the flag to true and
calls Thread.Interrupt() on each thread... but this doesn't seem to stop the
thread if it's blocked on a MessageQueue.Receive() operation.
Why is this?
And how can I solve this problem?
Someone suggested using a two-part loop, having the thread sleep for a while
and then check the message queue with a short timeout; this way, the thread
can be interrupted. But this seems a lot inefficient to me.
Any ideas?
Thanks
Massimo