fix: 修复并发控制、任务取消和更新检查问题#26
Conversation
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07cd3b5396
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| if (waitForFinish && _refreshTask is not null) | ||
| _refreshCancellationTokenSource = null; | ||
| _refreshTask = null; |
There was a problem hiding this comment.
Keep the old refresh task visible until stop completes
When StopAsync(waitForFinish: true) is in progress, this clears _refreshTask before the awaited refresh loop has actually finished unloading NVAPI. A concurrent StartAsync call can now observe the controller as stopped and launch a second RefreshLoopAsync while the first one is still running its finally, so NVAPI can be initialized/unloaded by overlapping monitor tasks; before this change _refreshTask stayed non-null until after the wait, causing such starts to no-op during shutdown.
Useful? React with 👍 / 👎.
🎯 Changes
1. GPUController 并发控制
GPUController引入_startStopLock,确保StartAsync和StopAsync操作的线程安全。IsStarted属性的读取方式,使其在锁内进行,避免竞态条件。StartAsync逻辑,防止并发启动导致的问题。StopAsync方法,确保任务取消和等待的正确顺序。_refreshCancellationTokenSource.CancelAsync()更改为同步的Cancel(),以简化取消流程。2. SpectrumKeyboardBacklightController 任务等待优化
TimeoutException和OperationCanceledException,增强错误处理能力。3. RetryHelper 任务取消处理
RetryHelper的默认异常匹配条件,使其不再重试因OperationCanceledException导致的失败。OperationCanceledException,确保取消操作能立即生效。4. UpdateChecker 更新频率修正
UpdateChecker中PerTwelveHours的时间间隔,使其从 13 小时精确到 12 小时。💡 Technical Highlights