From ff5b9e3b42925158b939de8701cc221aea1b57bf Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Wed, 13 May 2020 00:11:53 +0200 Subject: [PATCH] Minor adjustment Former-commit-id: 82fc6e92c9772bc96739573f7a183fa951abef3a --- FFMpegCore.Test/VideoTest.cs | 4 ++-- FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/FFMpegCore.Test/VideoTest.cs b/FFMpegCore.Test/VideoTest.cs index 644476f..9285433 100644 --- a/FFMpegCore.Test/VideoTest.cs +++ b/FFMpegCore.Test/VideoTest.cs @@ -643,7 +643,7 @@ public async Task Video_Cancel_Async() { await using var resStream = new MemoryStream(); var reader = new StreamPipeDataReader(resStream); - var writer = new RawVideoPipeDataWriter(BitmapSource.CreateBitmaps(256, System.Drawing.Imaging.PixelFormat.Format24bppRgb, 128, 128)); + var writer = new RawVideoPipeDataWriter(BitmapSource.CreateBitmaps(512, System.Drawing.Imaging.PixelFormat.Format24bppRgb, 128, 128)); var task = FFMpegArguments .FromPipe(writer) @@ -653,7 +653,7 @@ public async Task Video_Cancel_Async() .CancellableThrough(out var cancel) .ProcessAsynchronously(false); - await Task.Delay(100); + await Task.Delay(300); cancel(); var result = await task; diff --git a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs index c6f74ac..bdd6ea5 100644 --- a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs +++ b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs @@ -26,7 +26,7 @@ internal FFMpegArgumentProcessor(FFMpegArguments ffMpegArguments) public string Arguments => _ffMpegArguments.Text; - private event EventHandler _cancelEvent; + private event EventHandler CancelEvent = null!; public FFMpegArgumentProcessor NotifyOnProgress(Action onPercentageProgress, TimeSpan totalTimeSpan) { @@ -41,7 +41,7 @@ public FFMpegArgumentProcessor NotifyOnProgress(Action onTimeProgress) } public FFMpegArgumentProcessor CancellableThrough(out Action cancel) { - cancel = () => _cancelEvent?.Invoke(this, EventArgs.Empty); + cancel = () => CancelEvent?.Invoke(this, EventArgs.Empty); return this; } public bool ProcessSynchronously(bool throwOnError = true) @@ -53,7 +53,7 @@ void OnCancelEvent(object sender, EventArgs args) instance?.SendInput("q"); cancellationTokenSource.Cancel(); } - _cancelEvent += OnCancelEvent; + CancelEvent += OnCancelEvent; _ffMpegArguments.Pre(); try @@ -70,7 +70,7 @@ void OnCancelEvent(object sender, EventArgs args) } finally { - _cancelEvent -= OnCancelEvent; + CancelEvent -= OnCancelEvent; _ffMpegArguments.Post(); } @@ -92,7 +92,7 @@ void OnCancelEvent(object sender, EventArgs args) instance?.SendInput("q"); cancellationTokenSource.Cancel(); } - _cancelEvent += OnCancelEvent; + CancelEvent += OnCancelEvent; _ffMpegArguments.Pre(); try @@ -109,7 +109,7 @@ await Task.WhenAll(instance.FinishedRunning().ContinueWith(t => } finally { - _cancelEvent -= OnCancelEvent; + CancelEvent -= OnCancelEvent; _ffMpegArguments.Post(); }