private static void ServerThread(object data) { var pipeServer = new NamedPipeServerStream("TestPipe", PipeDirection.InOut, _numThread); var threadId = Thread.CurrentThread.ManagedThreadId; pipeServer.WaitForConnection(); Console.WriteLine($"Client connected on thread [{threadId}]"); try { var ss = new StreamString(pipeServer); ss.WriteString("I am the one true server!"); var filename = ss.ReadString(); var fileReader = new ReadFileToStream(ss, filename); Console.WriteLine($"Reading file:{filename} on thread [{threadId}] as users: {pipeServer.GetImpersonationUserName()}"); pipeServer.RunAsClient(fileReader.Start); } catch (Exception e) { Console.WriteLine(e); throw; } }
public ReadFileToStream(StreamString ss, string filename) { _ss = ss; _filename = filename; }