本文整理汇总了C#中System.IO.Pipes.NamedPipeClientStream.FlushAsync方法的典型用法代码示例。如果您正苦于以下问题:C# NamedPipeClientStream.FlushAsync方法的具体用法?C# NamedPipeClientStream.FlushAsync怎么用?C# NamedPipeClientStream.FlushAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Pipes.NamedPipeClientStream
的用法示例。
在下文中一共展示了NamedPipeClientStream.FlushAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProfileClientTestWorkerAsync
private async Task<UserProfileResultMock> CreateProfileClientTestWorkerAsync(string input, CancellationToken ct = default(CancellationToken)) {
string jsonResp = null;
using (NamedPipeClientStream client = new NamedPipeClientStream("Microsoft.R.Host.UserProfile.Creator{b101cc2d-156e-472e-8d98-b9d999a93c7a}")) {
await client.ConnectAsync(ct);
byte[] data = Encoding.Unicode.GetBytes(input);
await client.WriteAsync(data, 0, data.Length, ct);
await client.FlushAsync(ct);
byte[] responseRaw = new byte[1024];
var bytesRead = await client.ReadAsync(responseRaw, 0, responseRaw.Length, ct);
jsonResp = Encoding.Unicode.GetString(responseRaw, 0, bytesRead);
}
return Json.DeserializeObject<UserProfileResultMock>(jsonResp);
}
示例2: ProfileWorkerAsync
private async Task<RUserProfileServiceResponse> ProfileWorkerAsync(string name, string log, RUserProfileServiceRequest request, CancellationToken ct) {
using (NamedPipeClientStream client = new NamedPipeClientStream(name)) {
try {
await client.ConnectAsync(ct);
string jsonReq = JsonConvert.SerializeObject(request);
byte[] data = Encoding.Unicode.GetBytes(jsonReq.ToString());
await client.WriteAsync(data, 0, data.Length, ct);
await client.FlushAsync(ct);
byte[] responseRaw = new byte[1024];
var bytesRead = await client.ReadAsync(responseRaw, 0, responseRaw.Length, ct);
string jsonResp = Encoding.Unicode.GetString(responseRaw, 0, bytesRead);
return Json.DeserializeObject<RUserProfileServiceResponse>(jsonResp);
} catch (Exception ex) when (!ex.IsCriticalException()) {
_logger.LogError(log, request.Username);
return RUserProfileServiceResponse.Blank;
}
}
}