I'm using anonymous pipes to send commands between two processes. Usually everything works great but from time to time the command received by the consumer is truncated and only half of it comes through.
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 base64-converted pdf file with some additional data. The command written to the pipeWriter has the correct form (at least logs tell us that much) and the command received by the consumer is usually OK. Then, from time to time it's not and for some reason consumer gets only some portion of it.
When we try to send the same command again it will go through. Sending the command again will dispose the old consumer but the producer will stay the same.
Is there any known reason for this situation to occur? Am I missing something obvious?