using System.IO.Pipes; NamedPipeServerStream pipeServer = new NamedPipeServerStream("mypipe"); // pipe communication pipeServer.Dispose(); // release resources
using (NamedPipeServerStream pipeServer = new NamedPipeServerStream("mypipe")) { // pipe communication } // resources released automatically due to using statementIn this example, we use the C# using statement to ensure that the resources used by the NamedPipeServerStream instance are automatically released when the program exits the using block. The NamedPipeServerStream class is part of the .NET Framework's System.IO.Pipes package/library.