I am looking at code that was not written by me myself, and I am trying to understand what causes the application to crash.
I think that maybe it comes down to how he manages resources and manages flows.
The main parent thread creates a new application-level client (TCPMonitor), which then creates another class that processes TCP cells (TCPListen). This class spawns a new thread loop, which creates a new TCP socket client, reads the network stream on that socket, and then causes a synchronous Read () lock.
However, if a network error message occurs, the exception falls into the TCPListen stream loop and the event is returned back to the native TCPMonitor class. Then TCPMonitor checks to see if it contains an active instance of TCPListen, and if it calls Dispose () and sets the instance to Null.
Will TCPListen Read () still block the call? If this is the case, how can I guarantee that a Dispose call from the parent thread will break the child thread from the blocking call and correctly remove the thread and socket?
jaffa source share