From 4a6fb20aabe4d1340813169ffe299a8bb5cd958c Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Sat, 6 Mar 2021 23:33:48 +0100 Subject: [PATCH] reorder method Former-commit-id: 744489910610f4b2c72cf599c183581e7cef7096 --- FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs index ecc568f..06fca1a 100644 --- a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs +++ b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs @@ -90,17 +90,6 @@ void OnCancelEvent(object sender, int timeout) return HandleCompletion(throwOnError, errorCode, instance.ErrorData); } - private bool HandleCompletion(bool throwOnError, int exitCode, IReadOnlyList errorData) - { - if (throwOnError && exitCode != 0) - throw new FFMpegProcessException(exitCode, string.Join("\n", errorData)); - - _onPercentageProgress?.Invoke(100.0); - if (_totalTimespan.HasValue) _onTimeProgress?.Invoke(_totalTimespan.Value); - - return exitCode == 0; - } - public async Task ProcessAsynchronously(bool throwOnError = true) { using var instance = PrepareInstance(out var cancellationTokenSource); @@ -140,6 +129,17 @@ await Task.WhenAll(instance.FinishedRunning().ContinueWith(t => return HandleCompletion(throwOnError, errorCode, instance.ErrorData); } + private bool HandleCompletion(bool throwOnError, int exitCode, IReadOnlyList errorData) + { + if (throwOnError && exitCode != 0) + throw new FFMpegProcessException(exitCode, string.Join("\n", errorData)); + + _onPercentageProgress?.Invoke(100.0); + if (_totalTimespan.HasValue) _onTimeProgress?.Invoke(_totalTimespan.Value); + + return exitCode == 0; + } + private Instance PrepareInstance(out CancellationTokenSource cancellationTokenSource) { FFMpegHelper.RootExceptionCheck();