Escl: Add SearchTimeout option

This commit is contained in:
Ben Olden-Cooligan 2023-12-11 22:16:46 -08:00
parent 962159b2d4
commit ef64c4840d
2 changed files with 6 additions and 2 deletions

View File

@ -2,4 +2,8 @@
public class EsclOptions 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;
} }

View File

@ -56,7 +56,7 @@ internal class EsclScanDriver : IScanDriver
locator.Start(); locator.Start();
try try
{ {
await Task.Delay(2000, cancelToken); await Task.Delay(options.EsclOptions.SearchTimeout, cancelToken);
} }
catch (TaskCanceledException) catch (TaskCanceledException)
{ {
@ -221,7 +221,7 @@ internal class EsclScanDriver : IScanDriver
foundTcs.TrySetResult(service); 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.Logger = _scanningContext.Logger;
locator.Start(); locator.Start();
return await foundTcs.Task; return await foundTcs.Task;