AnonymousPipes - not getting all the data

I use anonymous pipes to send commands between two processes. Usually everything works fine, but from time to time the command received by the consumer is truncated, and only half of it passes.

This is how I send commands:

AnonymousPipeServerStream pipeServer = new AnonymousPipeServerStream(PipeDirection.Out,     HandleInheritability.Inheritable);
StreamWriterpipeWriter = new StreamWriter(this.pipeServer) { AutoFlush = true };
pipeWriter.WriteLine(command);

and this is how I read them:

AnonymousPipeClientStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, pipeId);
StreamReader pipeReader = new StreamReader(this.pipeClient);
string command = pipeReader.ReadLine();

The command is actually a small pdf file with base64 conversion with some additional data. The command written in pipeWriter has the correct form (at least the logs tell us about it), and the command received by the consumer is usually in order. Then from time to time this is not so and for some reason the consumer receives only part of it.

, . , .

- ? - ?

+3
2

Windows. " , - " " , ". , , , , , , , . winapi FlushFileBuffers().

- .NET , . , FlushFileBuffers() WaitForPipeDrain(). , Close() Dispose() . , - .

+2

WaitForPipeDrain, .

+3

All Articles