diff --git a/server/src/Hubs/DigitalTubesHub.cs b/server/src/Hubs/DigitalTubesHub.cs index 999d9b7..4eb879f 100644 --- a/server/src/Hubs/DigitalTubesHub.cs +++ b/server/src/Hubs/DigitalTubesHub.cs @@ -70,7 +70,7 @@ public class DigitalTubesHub : Hub, IDigitalTubesHub private readonly IHubContext _hubContext; private readonly Database.UserManager _userManager = new(); - private ConcurrentDictionary _scanTasks = new(); + private static ConcurrentDictionary _scanTasks = new(); public DigitalTubesHub(IHubContext hubContext) { diff --git a/server/src/Hubs/OscilloscopeHub.cs b/server/src/Hubs/OscilloscopeHub.cs index fffd71e..ecf908f 100644 --- a/server/src/Hubs/OscilloscopeHub.cs +++ b/server/src/Hubs/OscilloscopeHub.cs @@ -86,7 +86,7 @@ public class OscilloscopeHub : Hub, IOscilloscopeHub private readonly IHubContext _hubContext; private readonly Database.UserManager _userManager = new(); - private ConcurrentDictionary _scanTasks = new(); + private static ConcurrentDictionary _scanTasks = new(); public OscilloscopeHub(IHubContext hubContext) { @@ -192,9 +192,7 @@ public class OscilloscopeHub : Hub, IOscilloscopeHub var scanTaskInfo = new OscilloscopeScanTaskInfo(client); scanTaskInfo.ScanTask = ScanTask(scanTaskInfo, Context.ConnectionId); - _scanTasks[key] = scanTaskInfo; - - return result.Value; + return _scanTasks.TryAdd(key, scanTaskInfo); } catch (Exception ex) {