From 02af59c37e5b446802a646433a6c1e90fe50bf07 Mon Sep 17 00:00:00 2001 From: SikongJueluo Date: Wed, 20 Aug 2025 17:20:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A4=BA=E6=B3=A2?= =?UTF-8?q?=E5=99=A8=E4=B8=8E=E6=95=B0=E7=A0=81=E7=AE=A1=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/Hubs/DigitalTubesHub.cs | 2 +- server/src/Hubs/OscilloscopeHub.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) 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) {