I have two applications and I used named pipes to communicate between them. The pipes is working absolutely fine thanks to a code project article. But I noticed that if both the apps don't start. Application 'A' keeps waiting for application 'B' and app 'A' does not start. The following is a snippet which creates an aync pipe:
NamedPipeServerStream pipeServer = new NamedPipeServerStream(PipeName, PipeDirection.In, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
pipeServer.BeginWaitForConnection(new AsyncCallback(WaitForConnectionCallBack), pipeServer);
This is the same way I create the pipes in both App 'A' and 'B',each of the applications would have a client as well. This is how I send messages from the client:
NamedPipeClientStream pipeStream = new NamedPipeClientStream(".", PipeName, PipeDirection.Out, PipeOptions.Asynchronous);
// The connect function will indefinitely wait for the pipe to become available
// If that is not acceptable specify a maximum waiting time (in ms)
pipeStream.Connect(TimeOut);
byte[] _buffer = Encoding.UTF8.GetBytes(SendStr);
pipeStream.BeginWrite(_buffer, 0, _buffer.Length, AsyncSend, pipeStream);
So how can I improve the performance so that both the applications run without waiting? As of now,I have kept a timeout of 1000 ms. Should I reduce the timeout period? Or am I missing something,which looks likely :)