A new instance of TcpClient connects to the remote host. Its NetworkStream is retrieved and saved. Should I also store TcpClient itself to make sure this is not garbage collection?
In case you answer "You must save it in order to be able to dispose of it": In my particular case, TcpClient usually lives for a long time (application lifetime), so getting rid of it is not necessary. However, I agree that in general it must be saved in order to be able to call Dispose.
source
share