Skip to content

Commit

Permalink
Escl: Add SearchTimeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Dec 12, 2023
1 parent 962159b commit ef64c48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NAPS2.Sdk/Scan/EsclOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

public class EsclOptions
{
/// <summary>
/// The maximum time (in ms) to search for ESCL devices when calling GetDevices or at the start of a scan.
/// </summary>
public int SearchTimeout { get; set; } = 5000;
}
4 changes: 2 additions & 2 deletions NAPS2.Sdk/Scan/Internal/Escl/EsclScanDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task GetDevices(ScanOptions options, CancellationToken cancelToken,
locator.Start();
try
{
await Task.Delay(2000, cancelToken);
await Task.Delay(options.EsclOptions.SearchTimeout, cancelToken);
}
catch (TaskCanceledException)
{
Expand Down Expand Up @@ -221,7 +221,7 @@ private static void VerifyStatus(EsclScannerStatus status, EsclScanSettings scan
foundTcs.TrySetResult(service);
}
});
Task.Delay(2000).ContinueWith(_ => foundTcs.TrySetResult(null)).AssertNoAwait();
Task.Delay(options.EsclOptions.SearchTimeout).ContinueWith(_ => foundTcs.TrySetResult(null)).AssertNoAwait();
locator.Logger = _scanningContext.Logger;
locator.Start();
return await foundTcs.Task;
Expand Down

0 comments on commit ef64c48

Please sign in to comment.