From 563b5632f9bd98836416d0358494e51cc431f1ab Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Mon, 11 May 2020 00:04:53 +0200 Subject: [PATCH] Add missing using for disposable Former-commit-id: 48bb95e178250880648e38437f9779835485a67c --- FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs index e86bf5c..9417c12 100644 --- a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs +++ b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs @@ -39,7 +39,7 @@ public FFMpegArgumentProcessor NotifyOnProgress(Action? onTimeProgress public bool ProcessSynchronously() { FFMpegHelper.RootExceptionCheck(FFMpegOptions.Options.RootDirectory); - var instance = new Instance(FFMpegOptions.Options.FFmpegBinary, _ffMpegArguments.Text); + using var instance = new Instance(FFMpegOptions.Options.FFmpegBinary, _ffMpegArguments.Text); instance.DataReceived += OutputData; var errorCode = -1; @@ -61,7 +61,8 @@ public async Task ProcessAsynchronously() { FFMpegHelper.RootExceptionCheck(FFMpegOptions.Options.RootDirectory); using var instance = new Instance(FFMpegOptions.Options.FFmpegBinary, _ffMpegArguments.Text); - instance.DataReceived += OutputData; + if (_onTimeProgress != null || (_onPercentageProgress != null && _totalTimespan != null)) + instance.DataReceived += OutputData; var errorCode = -1; _ffMpegArguments.Pre(); @@ -88,7 +89,6 @@ private void OutputData(object sender, (DataType Type, string Data) msg) #if DEBUG Trace.WriteLine(msg.Data); #endif - if (_onTimeProgress == null && (_onPercentageProgress == null || _totalTimespan == null)) return; var match = ProgressRegex.Match(msg.Data); if (!match.Success) return;