AnonymousPipeClientStream Constructors

Definitie

Initialiseert een nieuw exemplaar van de AnonymousPipeClientStream klasse.

Overloads

Name Description
AnonymousPipeClientStream(String)

Initialiseert een nieuw exemplaar van de AnonymousPipeClientStream klasse met de opgegeven tekenreeksweergave van de pijpgreep.

AnonymousPipeClientStream(PipeDirection, SafePipeHandle)

Initialiseert een nieuw exemplaar van de AnonymousPipeClientStream klasse vanuit de opgegeven ingang.

AnonymousPipeClientStream(PipeDirection, String)

Initialiseert een nieuw exemplaar van de AnonymousPipeClientStream klasse met de opgegeven pijprichting en een tekenreeksweergave van de pijpgreep.

AnonymousPipeClientStream(String)

Initialiseert een nieuw exemplaar van de AnonymousPipeClientStream klasse met de opgegeven tekenreeksweergave van de pijpgreep.

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)

Parameters

pipeHandleAsString
String

Een tekenreeks die de pijpgreep vertegenwoordigt.

Uitzonderingen

pipeHandleAsString is geen geldige pijpgreep.

Voorbeelden

In het volgende voorbeeld ziet u een manier om een tekenreeks van een bovenliggend proces naar een onderliggend proces te verzenden met behulp van anonieme pijpen. In dit voorbeeld wordt een AnonymousPipeClientStream object gemaakt in een onderliggend proces.

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

Opmerkingen

Voor constructors zonder parameter PipeDirection is Inde standaardrichting .

Van toepassing op

AnonymousPipeClientStream(PipeDirection, SafePipeHandle)

Initialiseert een nieuw exemplaar van de AnonymousPipeClientStream klasse vanuit de opgegeven ingang.

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);
public AnonymousPipeClientStream(System.IO.Pipes.PipeDirection direction, Microsoft.Win32.SafeHandles.SafePipeHandle safePipeHandle);
[<System.Security.SecurityCritical>]
new System.IO.Pipes.AnonymousPipeClientStream : System.IO.Pipes.PipeDirection * Microsoft.Win32.SafeHandles.SafePipeHandle -> System.IO.Pipes.AnonymousPipeClientStream
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)

Parameters

direction
PipeDirection

Een van de opsommingswaarden die de richting van de pijp bepalen.

Anonieme pijpen kunnen slechts in één richting zijn, dus direction kan niet worden ingesteld op InOut.

safePipeHandle
SafePipeHandle

Een veilige handgreep voor de pijp die door dit AnonymousPipeClientStream object wordt ingekapseld.

Kenmerken

Uitzonderingen

safePipeHandle is geen geldige ingang.

safePipeHandle is null.

direction is ingesteld op InOut.

Er is een I/O-fout opgetreden, zoals een schijffout.

– of –

De stream is gesloten.

Voorbeelden

In het volgende voorbeeld ziet u een manier om een tekenreeks van een bovenliggend proces naar een onderliggend proces te verzenden met behulp van anonieme pijpen. In dit voorbeeld wordt een AnonymousPipeClientStream object gemaakt in een onderliggend proces met een PipeDirection waarde van 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

Opmerkingen

Een PipeDirection waarde van InOut wordt niet ondersteund omdat anonieme pijpen in één richting zijn gedefinieerd.

Van toepassing op

AnonymousPipeClientStream(PipeDirection, String)

Initialiseert een nieuw exemplaar van de AnonymousPipeClientStream klasse met de opgegeven pijprichting en een tekenreeksweergave van de pijpgreep.

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

Parameters

direction
PipeDirection

Een van de opsommingswaarden die de richting van de pijp bepalen.

Anonieme pijpen kunnen slechts in één richting zijn, dus direction kan niet worden ingesteld op InOut.

pipeHandleAsString
String

Een tekenreeks die de pijpgreep vertegenwoordigt.

Kenmerken

Uitzonderingen

pipeHandleAsString is een ongeldige ingang.

pipeHandleAsString is null.

direction is ingesteld op InOut.

Voorbeelden

In het volgende voorbeeld ziet u een manier om een tekenreeks van een bovenliggend proces naar een onderliggend proces te verzenden met behulp van anonieme pijpen. In dit voorbeeld wordt een AnonymousPipeClientStream object gemaakt in een onderliggend proces met een PipeDirection waarde van In.

//<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>

Opmerkingen

Een PipeDirection waarde van InOut wordt niet ondersteund omdat anonieme pijpen in één richting zijn gedefinieerd.

Van toepassing op