well its a garbage collection question as well.
After TcpClient.Close() I take it the garbage collector does its job and removes it from memory etc.
or am I wrong?
(Chris128 put your handdown and let somebody else answer :) )
Printable View
well its a garbage collection question as well.
After TcpClient.Close() I take it the garbage collector does its job and removes it from memory etc.
or am I wrong?
(Chris128 put your handdown and let somebody else answer :) )
I would assume it would dispose the TCPClient (or mark it for disposal at least).
What I don't know is that if you Close the TCPClient, and leave the NetworkStream open, whether the reference to the NetworkStream will keep the TCPClient in memory and prevent the Garbage Collector from removing the TCPClient. If you make sure that you close the network stream before you close the TCPClient, I can't see why it wouldn't be collected.
http://msdn.microsoft.com/en-us/libr...se(VS.80).aspx
"The Close method marks the instance as disposed but does not close the TCP connection. Calling this method does not release the NetworkStream that is used to send and receive data. You must call the Close method to close the stream and the TCP connection."
If you use CLRProfiler, you should be able to test whether the TCPClient has been disposed properly.
haha I could not have answered this one anyway :) because I didnt know this:
Quote:
Calling this method does not release the NetworkStream that is used to send and receive data