Don't show "no devices" message after cancellation

This commit is contained in:
Ben Olden-Cooligan 2023-02-28 17:42:06 -08:00
parent f17d3459a4
commit 89831537cb
2 changed files with 5 additions and 1 deletions

View File

@ -46,6 +46,7 @@ public class EtoDevicePrompt : IDevicePrompt
{
var deviceForm = _formFactory.Create<SelectDeviceForm>();
deviceForm.AsyncDevices = devices;
deviceForm.AsyncCancelToken = cts.Token;
deviceForm.ShowModal();
cts.Cancel();
return deviceForm.SelectedDevice;

View File

@ -1,3 +1,4 @@
using System.Threading;
using Eto.Drawing;
using Eto.Forms;
using NAPS2.EtoForms.Layout;
@ -85,7 +86,7 @@ public class SelectDeviceForm : EtoDialogBase
Invoker.Current.Invoke(() =>
{
_spinner.Visible = false;
if (_lazyDeviceList.Count == 0)
if (_lazyDeviceList.Count == 0 && !AsyncCancelToken.IsCancellationRequested)
{
Close();
_errorOutput.DisplayError(SdkResources.NoDevicesFound);
@ -101,6 +102,8 @@ public class SelectDeviceForm : EtoDialogBase
public IAsyncEnumerable<ScanDevice>? AsyncDevices { get; set; }
public CancellationToken AsyncCancelToken { get; set; }
public List<ScanDevice>? DeviceList { get; set; }
public ScanDevice? SelectedDevice { get; private set; }