Suppress JsonRPC Empty Response Exception and refactor code

This commit is contained in:
Hongtao Zhang 2022-08-18 09:37:41 -04:00
parent 76d23aba9b
commit c3dd3b1851
No known key found for this signature in database
GPG key ID: 75F655B91C7AC9BB

View file

@ -254,6 +254,14 @@ namespace Flow.Launcher.Core.Plugin
return Stream.Null;
}
var sourceBuffer = BufferManager.GetStream();
var errorBuffer = BufferManager.GetStream();
var sourceCopyTask = process.StandardOutput.BaseStream.CopyToAsync(sourceBuffer, token);
var errorCopyTask = process.StandardError.BaseStream.CopyToAsync(errorBuffer, token);
token.Register(() =>
{
try
@ -266,14 +274,6 @@ namespace Flow.Launcher.Core.Plugin
}
});
var sourceBuffer = BufferManager.GetStream();
var errorBuffer = BufferManager.GetStream();
var sourceCopyTask = process.StandardOutput.BaseStream.CopyToAsync(sourceBuffer, token);
var errorCopyTask = process.StandardError.BaseStream.CopyToAsync(errorBuffer, token);
try
{
// token expire won't instantly trigger the exception,