reorder method

Former-commit-id: 7444899106
This commit is contained in:
Malte Rosenbjerg 2021-03-06 23:33:48 +01:00
parent f20c25d2ee
commit 4a6fb20aab

View file

@ -90,17 +90,6 @@ void OnCancelEvent(object sender, int timeout)
return HandleCompletion(throwOnError, errorCode, instance.ErrorData); return HandleCompletion(throwOnError, errorCode, instance.ErrorData);
} }
private bool HandleCompletion(bool throwOnError, int exitCode, IReadOnlyList<string> 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<bool> ProcessAsynchronously(bool throwOnError = true) public async Task<bool> ProcessAsynchronously(bool throwOnError = true)
{ {
using var instance = PrepareInstance(out var cancellationTokenSource); using var instance = PrepareInstance(out var cancellationTokenSource);
@ -140,6 +129,17 @@ await Task.WhenAll(instance.FinishedRunning().ContinueWith(t =>
return HandleCompletion(throwOnError, errorCode, instance.ErrorData); return HandleCompletion(throwOnError, errorCode, instance.ErrorData);
} }
private bool HandleCompletion(bool throwOnError, int exitCode, IReadOnlyList<string> 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) private Instance PrepareInstance(out CancellationTokenSource cancellationTokenSource)
{ {
FFMpegHelper.RootExceptionCheck(); FFMpegHelper.RootExceptionCheck();