fix: 尝试修复示波器与旋转编码器无法工作的问题
This commit is contained in:
@@ -212,11 +212,10 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, 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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user