C #, is there such a thing as a streaming stream?

I redirect the process output to a thread reader, which I read later. My problem is that I am using multiple threads that MUST have separate instances of this thread. When I go to read this stream, the streams are washed out and start to become strangely tangled.

Is there such a thing as creating a thread safe thread?
EDIT: I put the locks on ReadToEnd on the streamreader and on the line where I did: reader = proc.StandardOutput;

+5
source share
3 answers

SyncrhonizedStream, / .., SynchronizedStream

var syncStream = Stream.Synchronized(inStream);

syncStream , , , inStream .

SynchronizedStream /, , .

Edit:

, SynchronizedReader/SynchronizedWriter .

var reader = TextReader.Synchronized(process.StandardOutput);
+12

", " . - , , / . ( ) / .

+1

All Articles