Is there a way in C# to replace all the ObjectDisposedException
thrown by an instance of a NetworkStresm
with MyException
?
The purpose of this is that I want to read and write the stream while other threads may dispose it. And that's just fine - when the stream is disposed the exception is thrown and I handle it and it's part of the normal flow of the program (since the client may just disconnect). As opposed to other ObjectDisposedException
of other objects that are really an error, a bug in my code.
So if I could make the stream throw MyException
instead of the regular ObjectDisposedException
, I could treat it differently.
Any other suggestions to accomplish this purpose are good as well.
Thanks!