AnonymousPipeClientStream.TransmissionMode 屬性

定義

取得目前管道支援的管道傳輸模式。

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

屬性值

目前管道支援的 PipeTransmissionMode

屬性

範例

下列範例會使用匿名管道,將字串從父進程傳送至子進程。 在此範例中, AnonymousPipeClientStream 會在子進程中建立 物件,並將 TransmissionMode 顯示至主控台。

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>

備註

匿名管道不支持 PipeTransmissionMode.Message 讀取模式。 因為這個屬性的預設值是 PipeTransmissionMode.Byte,所以永遠不會有理由在程式代碼中設定這個屬性。

適用於

產品 版本
.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
.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