Cancel on exit

This commit is contained in:
Malte Rosenbjerg 2020-10-25 18:23:55 +01:00
parent 26f5b0f4f4
commit 31685da18a

View file

@ -55,6 +55,7 @@ void OnCancelEvent(object sender, EventArgs args)
cancellationTokenSource.Cancel(); cancellationTokenSource.Cancel();
} }
CancelEvent += OnCancelEvent; CancelEvent += OnCancelEvent;
instance.Exited += delegate { cancellationTokenSource.Cancel(); };
_ffMpegArguments.Pre(); _ffMpegArguments.Pre();
try try
@ -128,7 +129,6 @@ private Instance PrepareInstance(out CancellationTokenSource cancellationTokenSo
FFMpegHelper.RootExceptionCheck(); FFMpegHelper.RootExceptionCheck();
FFMpegHelper.VerifyFFMpegExists(); FFMpegHelper.VerifyFFMpegExists();
var instance = new Instance(FFMpegOptions.Options.FFmpegBinary(), _ffMpegArguments.Text); var instance = new Instance(FFMpegOptions.Options.FFmpegBinary(), _ffMpegArguments.Text);
instance.DataReceived += OutputData;
cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource = new CancellationTokenSource();
if (_onTimeProgress != null || (_onPercentageProgress != null && _totalTimespan != null)) if (_onTimeProgress != null || (_onPercentageProgress != null && _totalTimespan != null))