G
Guest
I am writing a server component that will raise various "events" using UDP
multicast events. A number of winform clients will begin receiving these
events on a background thread, listening on the muticast address.
My question is, is there a way of shutting down these threads without
calling Thread.Abort, e.g. when the user shutsdown the application.
If I use the async BeginReceiveFrom method, I still have to call
EndReceiveFrom to ensure I do not leak resources. However, this will block,
and there is no timeout option. I did consider sending a "terminate" event to
the socket, but then realised this would be sent to the multicast address,
and so to all the other listening clients.
The only option I see is to store a refence to the listening thread, and
call Abort on it when I want to shutdown, and trap the resulting exception.
Any alternative suggestions appreciated.
Dan
multicast events. A number of winform clients will begin receiving these
events on a background thread, listening on the muticast address.
My question is, is there a way of shutting down these threads without
calling Thread.Abort, e.g. when the user shutsdown the application.
If I use the async BeginReceiveFrom method, I still have to call
EndReceiveFrom to ensure I do not leak resources. However, this will block,
and there is no timeout option. I did consider sending a "terminate" event to
the socket, but then realised this would be sent to the multicast address,
and so to all the other listening clients.
The only option I see is to store a refence to the listening thread, and
call Abort on it when I want to shutdown, and trap the resulting exception.
Any alternative suggestions appreciated.
Dan