From 4c9b9cd3d64593639be5d8252153497a48456734 Mon Sep 17 00:00:00 2001 From: SikongJueluo Date: Wed, 20 Aug 2025 16:40:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=A4=BA=E6=B3=A2=E5=99=A8=E4=B8=8E=E6=97=8B=E8=BD=AC=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E5=99=A8=E6=97=A0=E6=B3=95=E5=B7=A5=E4=BD=9C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/Hubs/OscilloscopeHub.cs | 7 +++---- src/components/Oscilloscope/OscilloscopeManager.ts | 6 +++--- src/stores/Peripherals/RotaryEncoder.ts | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/server/src/Hubs/OscilloscopeHub.cs b/server/src/Hubs/OscilloscopeHub.cs index 66c3a94..38da0db 100644 --- a/server/src/Hubs/OscilloscopeHub.cs +++ b/server/src/Hubs/OscilloscopeHub.cs @@ -212,11 +212,10 @@ public class OscilloscopeHub : Hub, IOscilloscopeHub var key = (board.ID.ToString(), Context.ConnectionId); - if (_scanTasks.TryRemove(key, out var scanInfo)) + if (_scanTasks.TryRemove(key, out var taskInfo)) { - scanInfo.CTS.Cancel(); - if (scanInfo.ScanTask != null) await scanInfo.ScanTask; - scanInfo.CTS.Dispose(); + taskInfo.CTS.Cancel(); + if (taskInfo.ScanTask != null) taskInfo.ScanTask.Wait(); var result = await client.SetCaptureEnable(false); if (!result.IsSuccessful) diff --git a/src/components/Oscilloscope/OscilloscopeManager.ts b/src/components/Oscilloscope/OscilloscopeManager.ts index 71bf682..23f79ad 100644 --- a/src/components/Oscilloscope/OscilloscopeManager.ts +++ b/src/components/Oscilloscope/OscilloscopeManager.ts @@ -84,7 +84,7 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState( clearHub(); }); - function initHub() { + async function initHub() { if (oscilloscopeHub.value) return; const connection = AuthManager.createHubConnection("OscilloscopeHub"); @@ -96,7 +96,7 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState( connection, oscilloscopeReceiver, ); - connection.start(); + await connection.start(); oscilloscopeHub.value = { connection, proxy }; } @@ -252,12 +252,12 @@ const [useProvideOscilloscope, useOscilloscopeState] = createInjectionState( alert.warn("当前没有正在进行的捕获操作", 2000); return; } - isCapturing.value = false; const release = await operationMutex.acquire(); try { const proxy = getHubProxy(); const stopped = await proxy.stopCapture(); if (!stopped) throw new Error("无法停止捕获"); + isCapturing.value = false; alert.info("捕获已停止", 2000); } catch (error) { alert.error("停止捕获失败", 3000); diff --git a/src/stores/Peripherals/RotaryEncoder.ts b/src/stores/Peripherals/RotaryEncoder.ts index 28a43b4..7dd11b7 100644 --- a/src/stores/Peripherals/RotaryEncoder.ts +++ b/src/stores/Peripherals/RotaryEncoder.ts @@ -30,7 +30,7 @@ export const useRotaryEncoder = defineStore("RotaryEncoder", () => { clearHub(); }); - function initHub() { + async function initHub() { if (rotaryEncoderHub.value) return; const connection = AuthManager.createHubConnection("RotaryEncoderHub"); const proxy = @@ -39,7 +39,7 @@ export const useRotaryEncoder = defineStore("RotaryEncoder", () => { connection, rotaryEncoderReceiver, ); - connection.start(); + await connection.start(); rotaryEncoderHub.value = { connection, proxy }; }