Link to home
Start Free TrialLog in
Avatar of louis04
louis04

asked on

is the close method on networkstream thread safe?

Is it thread safe to call the close method of a network stream while the another thread is using the stream and blocked on the read method?
What I am after is the best way to interrupt a read or write that is blocked waiting to receive or send data. I of course need to do this from another thread.
Avatar of ripahoratiu
ripahoratiu
Flag of Romania image

You have ReadTimeout and WriteTimeout, make use of them.
Avatar of louis04
louis04

ASKER

setting timeouts is fine for normal operation but I want to be able to shutdown the program at will so I need to interrupt the blocked read or write - does setting ReadTimeout to zero during a blocked read make it return immediately?
ASKER CERTIFIED SOLUTION
Avatar of ripahoratiu
ripahoratiu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial