R
roger beniot
I have a program that launches multiple threads with a ThreadStart
method like the following (using System.Net.Sockets.Socket for UDP
packet transfers to a server):
ThreadStart pseudo code:
Connect
Receive response
Send Connect ACK
Send request for wml page
Receive wml page
Disconnect
Because I am using the blocking Socket calls to connect, send and
receive it is possible for the thread to get stuck in a blocked state.
I would like to be able to figure out when the thread is in the
blocked state and somehow stop/kill and then restart the thread again.
I tried using a System.Timers.Timer to wait on each blocking call… If
the timer interval expired then the Timer Elapsed event would be fired
and I could send an event back to the creator of the thread to kill
and restart the thread (killing via the Thread.Abort method).
However this has created multiple problems (specifically threads never
end up finishing, seemingly getting stuck in an endless loop).
So my question… Is there a way to accomplish this? Can someone
provide a basic outline or a hint at what methodologies I'm missing?
Many thanks in advance,
roger beniot
method like the following (using System.Net.Sockets.Socket for UDP
packet transfers to a server):
ThreadStart pseudo code:
Connect
Receive response
Send Connect ACK
Send request for wml page
Receive wml page
Disconnect
Because I am using the blocking Socket calls to connect, send and
receive it is possible for the thread to get stuck in a blocked state.
I would like to be able to figure out when the thread is in the
blocked state and somehow stop/kill and then restart the thread again.
I tried using a System.Timers.Timer to wait on each blocking call… If
the timer interval expired then the Timer Elapsed event would be fired
and I could send an event back to the creator of the thread to kill
and restart the thread (killing via the Thread.Abort method).
However this has created multiple problems (specifically threads never
end up finishing, seemingly getting stuck in an endless loop).
So my question… Is there a way to accomplish this? Can someone
provide a basic outline or a hint at what methodologies I'm missing?
Many thanks in advance,
roger beniot