Use WaitForExitAsync extension method in AttachmentExtractor
This commit is contained in:
parent
97c36d11d4
commit
48bbcbb426
|
@ -166,19 +166,15 @@ namespace MediaBrowser.MediaEncoding.Attachments
|
||||||
};
|
};
|
||||||
var process = new Process
|
var process = new Process
|
||||||
{
|
{
|
||||||
StartInfo = startInfo
|
StartInfo = startInfo,
|
||||||
|
EnableRaisingEvents = true
|
||||||
};
|
};
|
||||||
|
|
||||||
_logger.LogInformation("{File} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
_logger.LogInformation("{File} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
||||||
|
|
||||||
process.Start();
|
process.Start();
|
||||||
|
|
||||||
var processTcs = new TaskCompletionSource<bool>();
|
var ranToCompletion = await process.WaitForExitAsync(cancellationToken);
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
process.Exited += (sender, args) => processTcs.TrySetResult(true);
|
|
||||||
var unregister = cancellationToken.Register(() => processTcs.TrySetResult(process.HasExited));
|
|
||||||
var ranToCompletion = await processTcs.Task.ConfigureAwait(false);
|
|
||||||
unregister.Dispose();
|
|
||||||
|
|
||||||
if (!ranToCompletion)
|
if (!ranToCompletion)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user