Edit

Share via


AnonymousPipeClientStream.ReadMode Property

Definition

Sets the reading mode for the AnonymousPipeClientStream object.

C#
public override System.IO.Pipes.PipeTransmissionMode ReadMode { set; }
C#
public override System.IO.Pipes.PipeTransmissionMode ReadMode { [System.Security.SecurityCritical] set; }

Property Value

The PipeTransmissionMode for the AnonymousPipeClientStream object.

Attributes

Exceptions

The transmission mode is not valid. For anonymous pipes, only Byte is supported.

The transmission mode is Message.

The connection is broken or another I/O error occurs.

The pipe is closed.

Examples

The following example sends a string from a parent process to a child process by using anonymous pipes. In this example, an AnonymousPipeClientStream object is created in a child process.

C#
//<snippet01>
using System;
using System.IO;
using System.IO.Pipes;

class PipeClient
{
    static void Main(string[] args)
    {
        if (args.Length > 0)
        {
            using (PipeStream pipeClient =
                new AnonymousPipeClientStream(PipeDirection.In, args[0]))
            {
                Console.WriteLine("[CLIENT] Current TransmissionMode: {0}.",
                   pipeClient.TransmissionMode);

                using (StreamReader sr = new StreamReader(pipeClient))
                {
                    // Display the read text to the console
                    string temp;

                    // Wait for 'sync message' from the server.
                    do
                    {
                        Console.WriteLine("[CLIENT] Wait for sync...");
                        temp = sr.ReadLine();
                    }
                    while (!temp.StartsWith("SYNC"));

                    // Read the server data and echo to the console.
                    while ((temp = sr.ReadLine()) != null)
                    {
                        Console.WriteLine("[CLIENT] Echo: " + temp);
                    }
                }
            }
        }
        Console.Write("[CLIENT] Press Enter to continue...");
        Console.ReadLine();
    }
}
//</snippet01>

Remarks

Anonymous pipes do not support the PipeTransmissionMode.Message read mode.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1