當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET AnonymousPipeServerStream.GetClientHandleAsString方法代碼示例

本文整理匯總了VB.NET中System.IO.Pipes.AnonymousPipeServerStream.GetClientHandleAsString方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET AnonymousPipeServerStream.GetClientHandleAsString方法的具體用法?VB.NET AnonymousPipeServerStream.GetClientHandleAsString怎麽用?VB.NET AnonymousPipeServerStream.GetClientHandleAsString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.Pipes.AnonymousPipeServerStream的用法示例。


在下文中一共展示了AnonymousPipeServerStream.GetClientHandleAsString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: PipeServer

'<snippet01>
Imports System.IO
Imports System.IO.Pipes
Imports System.Diagnostics

Class PipeServer
    Shared Sub Main()
        Dim pipeClient As New Process()

        pipeClient.StartInfo.FileName = "pipeClient.exe"

        Using pipeServer As New AnonymousPipeServerStream(PipeDirection.Out, _
            HandleInheritability.Inheritable)

            Console.WriteLine("[SERVER] Current TransmissionMode: {0}.",
                pipeServer.TransmissionMode)

            ' Pass the client process a handle to the server.
            pipeClient.StartInfo.Arguments = pipeServer.GetClientHandleAsString()
            pipeClient.StartInfo.UseShellExecute = false
            pipeClient.Start()

            pipeServer.DisposeLocalCopyOfClientHandle()

            Try
                ' Read user input and send that to the client process.
                Using sw As New StreamWriter(pipeServer)
                    sw.AutoFlush = true
                    ' Send a 'sync message' and wait for client to receive it.
                    sw.WriteLine("SYNC")
                    pipeServer.WaitForPipeDrain()
                    ' Send the console input to the client process.
                    Console.Write("[SERVER] Enter text: ")
                    sw.WriteLine(Console.ReadLine())
                End Using
            Catch e As IOException
                ' Catch the IOException that is raised if the pipe is broken
                ' or disconnected.
                Console.WriteLine("[SERVER] Error: {0}", e.Message)
            End Try
        End Using

        pipeClient.WaitForExit()
        pipeClient.Close()
        Console.WriteLine("[SERVER] Client quit. Server terminating.")
    End Sub
End Class
'</snippet01>
開發者ID:VB.NET開發者,項目名稱:System.IO.Pipes,代碼行數:48,代碼來源:AnonymousPipeServerStream.GetClientHandleAsString


注:本文中的System.IO.Pipes.AnonymousPipeServerStream.GetClientHandleAsString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。