Merge pull request #671 from Tthecreator/dev

Set EnableRaisingEvents correctly
This commit is contained in:
Andrew Rabert 2019-01-22 19:31:33 -05:00 committed by GitHub
commit 52dd570142
2 changed files with 10 additions and 14 deletions

View file

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

View file

@ -437,7 +437,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
UseShellExecute = false,
FileName = _mediaEncoder.EncoderPath,
Arguments = string.Format("{0} -i \"{1}\" -c:s srt \"{2}\"", encodingParam, inputPath, outputPath),
EnableRaisingEvents = true,
IsHidden = true,
ErrorDialog = false
});
@ -574,7 +574,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{
CreateNoWindow = true,
UseShellExecute = false,
EnableRaisingEvents = true,
FileName = _mediaEncoder.EncoderPath,
Arguments = processArgs,
IsHidden = true,