AnonymousPipeClientStream Construtores

Definição

Inicializa uma nova instância da classe AnonymousPipeClientStream.Initializes a new instance of the AnonymousPipeClientStream class.

Sobrecargas

AnonymousPipeClientStream(String)

Inicializa uma nova instância da classe AnonymousPipeClientStream com a representação especificada da cadeia de caracteres do identificador do pipe.Initializes a new instance of the AnonymousPipeClientStream class with the specified string representation of the pipe handle.

AnonymousPipeClientStream(PipeDirection, SafePipeHandle)

Inicializa uma nova instância da classe AnonymousPipeClientStream do identificador especificado.Initializes a new instance of the AnonymousPipeClientStream class from the specified handle.

AnonymousPipeClientStream(PipeDirection, String)

Inicializa uma nova instância da classe AnonymousPipeClientStream com a direção do pipe especificada e uma representação de cadeia de caracteres do identificador do pipe.Initializes a new instance of the AnonymousPipeClientStream class with the specified pipe direction and a string representation of the pipe handle.

AnonymousPipeClientStream(String)

Inicializa uma nova instância da classe AnonymousPipeClientStream com a representação especificada da cadeia de caracteres do identificador do pipe.Initializes a new instance of the AnonymousPipeClientStream class with the specified string representation of the pipe handle.

public:
 AnonymousPipeClientStream(System::String ^ pipeHandleAsString);
public AnonymousPipeClientStream (string pipeHandleAsString);
new System.IO.Pipes.AnonymousPipeClientStream : string -> System.IO.Pipes.AnonymousPipeClientStream
Public Sub New (pipeHandleAsString As String)

Parâmetros

pipeHandleAsString
String

Uma cadeia de caracteres que representa o identificador do pipe.A string that represents the pipe handle.

Exceções

pipeHandleAsString não é um identificador de pipe válido.pipeHandleAsString is not a valid pipe handle.

Exemplos

O exemplo a seguir demonstra uma maneira de enviar uma cadeia de caracteres de um processo pai para um processo filho usando pipes anônimos.The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. Neste exemplo, um AnonymousPipeClientStream objeto é criado em um processo filho.In this example, an AnonymousPipeClientStream object is created in a child process.

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(args[0]))
            {

                Console.WriteLine("Current TransmissionMode: {0}.",
                   pipeClient.TransmissionMode);

                // Anonymous Pipes do not support Message mode.
                try
                {
                    Console.WriteLine("Setting ReadMode to \"Message\".");
                    pipeClient.ReadMode = PipeTransmissionMode.Message;
                }
                catch (NotSupportedException e)
                {
                    Console.WriteLine("EXCEPTION: {0}", e.Message);
                }

                using (StreamReader sr = new StreamReader(pipeClient))
                {
                    // Display the read text to the console
                    string temp;
                    while ((temp = sr.ReadLine()) != null)
                    {
                        Console.WriteLine(temp);
                    }
                }
            }
        }
        Console.Write("Press Enter to continue...");
        Console.ReadLine();
    }
}
Imports System.IO
Imports System.IO.Pipes

Class PipeClient

    Shared Sub Main(ByVal args As String())
        If (args.Length > 0) Then

            Using pipeClient As New AnonymousPipeClientStream(args(0))

                Console.WriteLine("Current TransmissionMode: {0}.", _
                   pipeClient.TransmissionMode)

                ' Anonymous Pipes do not support Message mode.
                Try
                    Console.WriteLine("Setting ReadMode to 'Message'.")
                    pipeClient.ReadMode = PipeTransmissionMode.Message
                Catch e As NotSupportedException
                    Console.WriteLine("EXCEPTION: {0}", e.Message)
                End Try

                Using sr As New StreamReader(pipeClient)

                    ' Display the read text to the console
                    Dim temp As String
                    temp = sr.ReadLine()
                    While Not temp = Nothing
                        Console.WriteLine(temp)
                        temp = sr.ReadLine()
                    End While
                End Using
            End Using
        End If
        Console.Write("Press Enter to continue...")
        Console.ReadLine()
    End Sub
End Class

Comentários

Para construtores sem um PipeDirection parâmetro, a direção padrão é In .For constructors without a PipeDirection parameter, the default direction is In.

Aplica-se a

AnonymousPipeClientStream(PipeDirection, SafePipeHandle)

Inicializa uma nova instância da classe AnonymousPipeClientStream do identificador especificado.Initializes a new instance of the AnonymousPipeClientStream class from the specified handle.

public:
 AnonymousPipeClientStream(System::IO::Pipes::PipeDirection direction, Microsoft::Win32::SafeHandles::SafePipeHandle ^ safePipeHandle);
public AnonymousPipeClientStream (System.IO.Pipes.PipeDirection direction, Microsoft.Win32.SafeHandles.SafePipeHandle safePipeHandle);
[System.Security.SecurityCritical]
public AnonymousPipeClientStream (System.IO.Pipes.PipeDirection direction, Microsoft.Win32.SafeHandles.SafePipeHandle safePipeHandle);
new System.IO.Pipes.AnonymousPipeClientStream : System.IO.Pipes.PipeDirection * Microsoft.Win32.SafeHandles.SafePipeHandle -> System.IO.Pipes.AnonymousPipeClientStream
[<System.Security.SecurityCritical>]
new System.IO.Pipes.AnonymousPipeClientStream : System.IO.Pipes.PipeDirection * Microsoft.Win32.SafeHandles.SafePipeHandle -> System.IO.Pipes.AnonymousPipeClientStream
Public Sub New (direction As PipeDirection, safePipeHandle As SafePipeHandle)

Parâmetros

direction
PipeDirection

Um dos valores de enumeração que determina a direção do pipe.One of the enumeration values that determines the direction of the pipe.

Pipes anônimos só podem estar em uma direção, então direction não pode ser definido como InOut.Anonymous pipes can only be in one direction, so direction cannot be set to InOut.

safePipeHandle
SafePipeHandle

Um identificador seguro para o arquivo que este objeto AnonymousPipeClientStream encapsulará.A safe handle for the pipe that this AnonymousPipeClientStream object will encapsulate.

Atributos

Exceções

safePipeHandle não é um identificador válido.safePipeHandle is not a valid handle.

safePipeHandle é null.safePipeHandle is null.

direction é definido como InOut.direction is set to InOut.

Ocorreu um erro de E/S, como um erro de disco.An I/O error, such as a disk error, has occurred.

- ou --or-

O fluxo foi fechado.The stream has been closed.

Exemplos

O exemplo a seguir demonstra uma maneira de enviar uma cadeia de caracteres de um processo pai para um processo filho usando pipes anônimos.The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. Neste exemplo, um AnonymousPipeClientStream objeto é criado em um processo filho com um PipeDirection valor de In .In this example, an AnonymousPipeClientStream object is created in a child process with a PipeDirection value of In.

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(args[0]))
            {

                Console.WriteLine("Current TransmissionMode: {0}.",
                   pipeClient.TransmissionMode);

                // Anonymous Pipes do not support Message mode.
                try
                {
                    Console.WriteLine("Setting ReadMode to \"Message\".");
                    pipeClient.ReadMode = PipeTransmissionMode.Message;
                }
                catch (NotSupportedException e)
                {
                    Console.WriteLine("EXCEPTION: {0}", e.Message);
                }

                using (StreamReader sr = new StreamReader(pipeClient))
                {
                    // Display the read text to the console
                    string temp;
                    while ((temp = sr.ReadLine()) != null)
                    {
                        Console.WriteLine(temp);
                    }
                }
            }
        }
        Console.Write("Press Enter to continue...");
        Console.ReadLine();
    }
}
Imports System.IO
Imports System.IO.Pipes

Class PipeClient

    Shared Sub Main(ByVal args As String())
        If (args.Length > 0) Then

            Using pipeClient As New AnonymousPipeClientStream(args(0))

                Console.WriteLine("Current TransmissionMode: {0}.", _
                   pipeClient.TransmissionMode)

                ' Anonymous Pipes do not support Message mode.
                Try
                    Console.WriteLine("Setting ReadMode to 'Message'.")
                    pipeClient.ReadMode = PipeTransmissionMode.Message
                Catch e As NotSupportedException
                    Console.WriteLine("EXCEPTION: {0}", e.Message)
                End Try

                Using sr As New StreamReader(pipeClient)

                    ' Display the read text to the console
                    Dim temp As String
                    temp = sr.ReadLine()
                    While Not temp = Nothing
                        Console.WriteLine(temp)
                        temp = sr.ReadLine()
                    End While
                End Using
            End Using
        End If
        Console.Write("Press Enter to continue...")
        Console.ReadLine()
    End Sub
End Class

Comentários

Um PipeDirection valor de InOut não tem suporte porque Pipes anônimos são definidos como unidirecional.A PipeDirection value of InOut is not supported because anonymous pipes are defined to be one-way.

Aplica-se a

AnonymousPipeClientStream(PipeDirection, String)

Inicializa uma nova instância da classe AnonymousPipeClientStream com a direção do pipe especificada e uma representação de cadeia de caracteres do identificador do pipe.Initializes a new instance of the AnonymousPipeClientStream class with the specified pipe direction and a string representation of the pipe handle.

public:
 AnonymousPipeClientStream(System::IO::Pipes::PipeDirection direction, System::String ^ pipeHandleAsString);
public AnonymousPipeClientStream (System.IO.Pipes.PipeDirection direction, string pipeHandleAsString);
[System.Security.SecurityCritical]
public AnonymousPipeClientStream (System.IO.Pipes.PipeDirection direction, string pipeHandleAsString);
new System.IO.Pipes.AnonymousPipeClientStream : System.IO.Pipes.PipeDirection * string -> System.IO.Pipes.AnonymousPipeClientStream
[<System.Security.SecurityCritical>]
new System.IO.Pipes.AnonymousPipeClientStream : System.IO.Pipes.PipeDirection * string -> System.IO.Pipes.AnonymousPipeClientStream
Public Sub New (direction As PipeDirection, pipeHandleAsString As String)

Parâmetros

direction
PipeDirection

Um dos valores de enumeração que determina a direção do pipe.One of the enumeration values that determines the direction of the pipe.

Pipes anônimos só podem estar em uma direção, então direction não pode ser definido como InOut.Anonymous pipes can only be in one direction, so direction cannot be set to InOut.

pipeHandleAsString
String

Uma cadeia de caracteres que representa o identificador do pipe.A string that represents the pipe handle.

Atributos

Exceções

pipeHandleAsString é um identificador inválido.pipeHandleAsString is an invalid handle.

pipeHandleAsString é null.pipeHandleAsString is null.

direction é definido como InOut.direction is set to InOut.

Exemplos

O exemplo a seguir demonstra uma maneira de enviar uma cadeia de caracteres de um processo pai para um processo filho usando pipes anônimos.The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. Neste exemplo, um AnonymousPipeClientStream objeto é criado em um processo filho com um PipeDirection valor de In .In this example, an AnonymousPipeClientStream object is created in a child process with a PipeDirection value of In.

//<snippet01>
#using <System.Core.dll>

using namespace System;
using namespace System::IO;
using namespace System::IO::Pipes;

ref class PipeClient
{
public:
    static void Main(array<String^>^ args)
    {
        if (args->Length > 1)
        {
            PipeStream^ pipeClient = gcnew AnonymousPipeClientStream(PipeDirection::In, args[1]);

            Console::WriteLine("[CLIENT] Current TransmissionMode: {0}.",
                pipeClient->TransmissionMode);

            StreamReader^ sr = gcnew 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()) != nullptr)
            {
                Console::WriteLine("[CLIENT] Echo: " + temp);
            }
            sr->Close();
            pipeClient->Close();
        }
        Console::Write("[CLIENT] Press Enter to continue...");
        Console::ReadLine();
    }
};

int main()
{
    array<String^>^ args = Environment::GetCommandLineArgs();
    PipeClient::Main(args);
}
//</snippet01>
//<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>
'<snippet01>
Imports System.IO
Imports System.IO.Pipes

Class PipeClient
    Shared Sub Main(args() as String)
        If args.Length > 0 Then
            Using pipeClient As New AnonymousPipeClientStream(PipeDirection.In, args(0))
                Console.WriteLine("[CLIENT] Current TransmissionMode: {0}.", _
                   pipeClient.TransmissionMode)

                Using sr As New StreamReader(pipeClient)
                    ' Display the read text to the console
                    Dim temp As String

                    ' Wait for 'sync message' from the server.
                    Do
                        Console.WriteLine("[CLIENT] Wait for sync...")
                        temp = sr.ReadLine()
                    Loop While temp.StartsWith("SYNC") = False

                    ' Read the server data and echo to the console.
                    temp = sr.ReadLine()
                    While Not temp = Nothing
                        Console.WriteLine("[CLIENT] Echo: " + temp)
                        temp = sr.ReadLine()
                    End While
                End Using
            End Using
        End If
        Console.Write("[CLIENT] Press Enter to continue...")
        Console.ReadLine()
    End Sub
End Class
'</snippet01>

Comentários

Um PipeDirection valor de InOut não tem suporte porque Pipes anônimos são definidos como unidirecional.A PipeDirection value of InOut is not supported because anonymous pipes are defined to be one-way.

Aplica-se a