public static void Main() { Enumerable.Range(0, 2).ToList().ForEach(i => Task.Run(async() => { bool disconnected = false; var pipeServer = new NamedPipeServer("testpipe", 10, i); pipeServer.OnDisconnect = (() => { Console.WriteLine($"client {i} disconnected"); disconnected = true; }); Console.WriteLine($"{i}: Server initialized"); await pipeServer.WaitForConnectionAsync(); Console.WriteLine($"{i}: Client connected"); while (true) { string s = Console.ReadLine(); if (disconnected) { break; } var l = new List <int> { 1, 2, 3 }; /*int id = await pipeServer.SendAsync(new { s, l }); * Console.WriteLine("message sent"); * var result = await pipeServer.ReadAsync<object>(id);//*/ var result = await pipeServer.CallAsync <object, object>(new { s, l }); Console.WriteLine($"{i}: recieved {JsonConvert.SerializeObject(result)}"); } })); while (true) { ; } }