mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-24 09:44:47 +03:00
Merge pull request #10378 from Bond-009/waitforexitasync
Use Process.WaitForExitAsync added in .NET 5
This commit is contained in:
@@ -752,11 +752,15 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
timeoutMs = enableHdrExtraction ? DefaultHdrImageExtractionTimeout : DefaultSdrImageExtractionTimeout;
|
||||
}
|
||||
|
||||
ranToCompletion = await process.WaitForExitAsync(TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);
|
||||
|
||||
if (!ranToCompletion)
|
||||
try
|
||||
{
|
||||
StopProcess(processWrapper, 1000);
|
||||
await process.WaitForExitAsync(TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);
|
||||
ranToCompletion = true;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
process.Kill(true);
|
||||
ranToCompletion = false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -991,7 +995,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
return true;
|
||||
}
|
||||
|
||||
private class ProcessWrapper : IDisposable
|
||||
private sealed class ProcessWrapper : IDisposable
|
||||
{
|
||||
private readonly MediaEncoder _mediaEncoder;
|
||||
|
||||
@@ -1034,13 +1038,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
_mediaEncoder._runningProcesses.Remove(this);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
process.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
process.Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user