Skip to content

Commit

Permalink
b/291170927 Fix InvalidOperationException when cancelling wait (#1062)
Browse files Browse the repository at this point in the history
When cancalling the wait dialog that's shown during exit, it's
possible that the task completes before it can be cancelled.
  • Loading branch information
jpassing authored Jul 14, 2023
1 parent 9cf691d commit 7811c95
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand Down Expand Up @@ -50,7 +49,18 @@ public WaitDialog(

private void cancelButton_Click(object sender, EventArgs e)
{
this.cancellationSource.Cancel();
try
{
this.cancellationSource.Cancel();
}
catch
{
//
// Canceallation may fail if the task has been completed
// or cancelled already.
//
}

Close();
}

Expand Down

0 comments on commit 7811c95

Please sign in to comment.