private static void PipeConnectionCallBack(IAsyncResult ar) { Hoofdscherm main_form = (Hoofdscherm)((object[])ar.AsyncState)[1]; pipeServer = new NamedPipeServerStream("Drawit_pipeserver", PipeDirection.InOut, 15, PipeTransmissionMode.Message, PipeOptions.Asynchronous); result = pipeServer.BeginWaitForConnection(new AsyncCallback(PipeConnectionCallBack), new object[] { pipeServer, main_form }); NamedPipeServerStream pipe_server = (NamedPipeServerStream)((object[])ar.AsyncState)[0]; pipe_server.EndWaitForConnection(ar); StreamString ss = new StreamString(pipe_server); string filename = ss.ReadString(); main_form.Invoke((Action) delegate { main_form.OpenFile(filename); }); pipe_server.Close(); pipe_server.Dispose(); }