流不支持并行IO读取或写入操作不支持、操作、IO

2023-09-04 23:49:30 作者:懵懵懂懂、仅有的温存。

我使用的是网络数据流中读取一个 ASP.NET 应用程序从网络数据,我得到这个错误,而试图从流中读取:

I'm using a network stream to read data from network in an ASP.NET application and I get this error while trying to read from the stream:

流不支持并发IO读取或写入操作

这有时会发生。你知道吗?

It happens sometimes. Any idea ?

推荐答案

这听起来简直好像你正试图从不同的线程在同一时间做同流两种不同的操作。添加锁定显示器)或者互斥应有助于同步进入流

It sounds simply as though you are trying to do two different operations on the same stream at the same time from different threads. Adding a lock (Monitor) or Mutex should help synchronise access to the stream.