diff --git a/NAPS2.Lib/EtoForms/EtoDevicePrompt.cs b/NAPS2.Lib/EtoForms/EtoDevicePrompt.cs index c6da07f94..365548d71 100644 --- a/NAPS2.Lib/EtoForms/EtoDevicePrompt.cs +++ b/NAPS2.Lib/EtoForms/EtoDevicePrompt.cs @@ -46,6 +46,7 @@ public class EtoDevicePrompt : IDevicePrompt { var deviceForm = _formFactory.Create(); deviceForm.AsyncDevices = devices; + deviceForm.AsyncCancelToken = cts.Token; deviceForm.ShowModal(); cts.Cancel(); return deviceForm.SelectedDevice; diff --git a/NAPS2.Lib/EtoForms/Ui/SelectDeviceForm.cs b/NAPS2.Lib/EtoForms/Ui/SelectDeviceForm.cs index 5a6f14273..f1dbb9c87 100644 --- a/NAPS2.Lib/EtoForms/Ui/SelectDeviceForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/SelectDeviceForm.cs @@ -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? AsyncDevices { get; set; } + public CancellationToken AsyncCancelToken { get; set; } + public List? DeviceList { get; set; } public ScanDevice? SelectedDevice { get; private set; }