The NamedPipeServerStream.EndWaitForConnection method in C# is used to end an asynchronous operation that waits for a client to connect to a named pipe. This method blocks until a client is connected or an exception is thrown. It belongs to the System.IO.Pipes package library.
Example 1: NamedPipeServerStream server = new NamedPipeServerStream("mypipe"); server.BeginWaitForConnection(ar => { Console.WriteLine("Client connected!"); server.EndWaitForConnection(ar); }, null);
In this example, we create a named pipe server stream with the name "mypipe". We start an asynchronous operation to wait for a client to connect to the pipe using the BeginWaitForConnection method. When a client connects, we write a message to the console and then end the asynchronous operation using the EndWaitForConnection method.
Example 2: NamedPipeServerStream server = new NamedPipeServerStream("mypipe"); server.WaitForConnection(); Console.WriteLine("Client connected!"); server.Disconnect();
In this example, we create a named pipe server stream with the name "mypipe". We then use the WaitForConnection method to block until a client connects to the pipe. Once a client is connected, we write a message to the console and then disconnect the server from the client using the Disconnect method.
C# (CSharp) NamedPipeServerStream.EndWaitForConnection - 30 examples found. These are the top rated real world C# (CSharp) examples of NamedPipeServerStream.EndWaitForConnection extracted from open source projects. You can rate examples to help us improve the quality of examples.