标签:mission pipe vat dpi serve cti var mode read
28.2 C#的异步函数
private static async Task<string> IssueClientRequestAsync(string serverName, string message) { using (var pipe = new NamedPipeClientStream(serverName, "PipeName", PipeDirection.InOut, PipeOptions.Asynchronous | PipeOptions.WriteThrough)) { pipe.Connect(); //必须在ReadMode设置前连接 pipe.ReadMode = PipeTransmissionMode.Message; byte[] request = Encoding.UTF8.GetBytes(message); await pipe.WriteAsync(request, 0, request.Length); byte[] response = new byte[10000]; int bytesRead = await pipe.ReadAsync(response, 0, response.Length); return Encoding.UTF8.GetString(response, 0, bytesRead); } }
标签:mission pipe vat dpi serve cti var mode read
原文地址:https://www.cnblogs.com/kikyoqiang/p/10203197.html