From e787d33e5af4fac85e814645fbd0bb497b419561 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 20 Jun 2022 16:47:25 -0600 Subject: [PATCH] Fix NRE on cancel when there's nothing to cancel. --- Source/LibationWinForms/ProcessQueue/ProcessQueueControl.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/LibationWinForms/ProcessQueue/ProcessQueueControl.cs b/Source/LibationWinForms/ProcessQueue/ProcessQueueControl.cs index 7ba46dd7..e34e8ae2 100644 --- a/Source/LibationWinForms/ProcessQueue/ProcessQueueControl.cs +++ b/Source/LibationWinForms/ProcessQueue/ProcessQueueControl.cs @@ -212,7 +212,8 @@ namespace LibationWinForms.ProcessQueue private async void cancelAllBtn_Click(object sender, EventArgs e) { Queue.ClearQueue(); - await Queue.Current?.CancelAsync(); + if (Queue.Current is not null) + await Queue.Current.CancelAsync(); virtualFlowControl2.VirtualControlCount = Queue.Count; UpdateAllControls(); } @@ -331,7 +332,8 @@ namespace LibationWinForms.ProcessQueue ProcessBook item = Queue[queueIndex]; if (buttonName == nameof(panelClicked.cancelBtn)) { - await item.CancelAsync(); + if (item is not null) + await item.CancelAsync(); Queue.RemoveQueued(item); virtualFlowControl2.VirtualControlCount = Queue.Count; }