fix: 修复示波器与数码管无法关闭的问题

This commit is contained in:
SikongJueluo 2025-08-20 17:20:52 +08:00
parent 0932c8ba75
commit 02af59c37e
2 changed files with 3 additions and 5 deletions

View File

@ -70,7 +70,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
private readonly IHubContext<DigitalTubesHub, IDigitalTubesReceiver> _hubContext; private readonly IHubContext<DigitalTubesHub, IDigitalTubesReceiver> _hubContext;
private readonly Database.UserManager _userManager = new(); private readonly Database.UserManager _userManager = new();
private ConcurrentDictionary<string, DigitalTubesScanTaskInfo> _scanTasks = new(); private static ConcurrentDictionary<string, DigitalTubesScanTaskInfo> _scanTasks = new();
public DigitalTubesHub(IHubContext<DigitalTubesHub, IDigitalTubesReceiver> hubContext) public DigitalTubesHub(IHubContext<DigitalTubesHub, IDigitalTubesReceiver> hubContext)
{ {

View File

@ -86,7 +86,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
private readonly IHubContext<OscilloscopeHub, IOscilloscopeReceiver> _hubContext; private readonly IHubContext<OscilloscopeHub, IOscilloscopeReceiver> _hubContext;
private readonly Database.UserManager _userManager = new(); private readonly Database.UserManager _userManager = new();
private ConcurrentDictionary<string, OscilloscopeScanTaskInfo> _scanTasks = new(); private static ConcurrentDictionary<string, OscilloscopeScanTaskInfo> _scanTasks = new();
public OscilloscopeHub(IHubContext<OscilloscopeHub, IOscilloscopeReceiver> hubContext) public OscilloscopeHub(IHubContext<OscilloscopeHub, IOscilloscopeReceiver> hubContext)
{ {
@ -192,9 +192,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
var scanTaskInfo = new OscilloscopeScanTaskInfo(client); var scanTaskInfo = new OscilloscopeScanTaskInfo(client);
scanTaskInfo.ScanTask = ScanTask(scanTaskInfo, Context.ConnectionId); scanTaskInfo.ScanTask = ScanTask(scanTaskInfo, Context.ConnectionId);
_scanTasks[key] = scanTaskInfo; return _scanTasks.TryAdd(key, scanTaskInfo);
return result.Value;
} }
catch (Exception ex) catch (Exception ex)
{ {