|
@@ -105,26 +105,22 @@ namespace Emby.Server.Implementations.Diagnostics
|
|
{
|
|
{
|
|
return _process.WaitForExit(timeMs);
|
|
return _process.WaitForExit(timeMs);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public Task<bool> WaitForExitAsync(int timeMs)
|
|
public Task<bool> WaitForExitAsync(int timeMs)
|
|
{
|
|
{
|
|
- //if (_process.WaitForExit(100))
|
|
|
|
- //{
|
|
|
|
- // return Task.FromResult(true);
|
|
|
|
- //}
|
|
|
|
|
|
+ //Note: For this function to work correctly, the option EnableRisingEvents needs to be set to true.
|
|
|
|
+
|
|
|
|
+ if (HasExited)
|
|
|
|
+ {
|
|
|
|
+ return Task.FromResult(true);
|
|
|
|
+ }
|
|
|
|
|
|
- //timeMs -= 100;
|
|
|
|
timeMs = Math.Max(0, timeMs);
|
|
timeMs = Math.Max(0, timeMs);
|
|
|
|
|
|
var tcs = new TaskCompletionSource<bool>();
|
|
var tcs = new TaskCompletionSource<bool>();
|
|
|
|
|
|
var cancellationToken = new CancellationTokenSource(timeMs).Token;
|
|
var cancellationToken = new CancellationTokenSource(timeMs).Token;
|
|
|
|
|
|
- if (HasExited)
|
|
|
|
- {
|
|
|
|
- return Task.FromResult(true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
_process.Exited += (sender, args) => tcs.TrySetResult(true);
|
|
_process.Exited += (sender, args) => tcs.TrySetResult(true);
|
|
|
|
|
|
cancellationToken.Register(() => tcs.TrySetResult(HasExited));
|
|
cancellationToken.Register(() => tcs.TrySetResult(HasExited));
|