Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes thread safety issues when calling work control functions (ToolStopWork and ToolSleep) through the plugin API, which previously caused InvalidOperationException when non-UI threads attempted to directly manipulate WPF controls.
- Wraps UI operations in
Dispatcher.Invokefor thread-safe access to WPF controls - Adds project configuration changes for Windows targeting and self-contained deployment
- Improves error handling by replacing label displays with message boxes
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| VPet.Plugin.ChatVPet.csproj | Adds Windows targeting and self-contained deployment configuration |
| CVP_Tool.cs | Wraps work control operations in Dispatcher.Invoke for thread safety |
| CVPTTalkAPI.cs | Replaces label error displays with message boxes and adds thread safety |
Comments suppressed due to low confidence (3)
VPet.Plugin.ChatVPet/VPet.Plugin.ChatVPet.csproj:9
- The property name should use PascalCase. Change 'selfContained' to 'SelfContained' to follow MSBuild property naming conventions.
<selfContained>true</selfContained>
VPet.Plugin.ChatVPet/CVP_Tool.cs:89
- The removed line was calling WorkTimer.Stop() outside of Dispatcher.Invoke, but this call is now missing from the ToolSleep method. The work timer should be stopped before checking the state or within the Dispatcher.Invoke block.
{
VPet.Plugin.ChatVPet/CVPTTalkAPI.cs:161
- [nitpick] The method name 'DisplayThinkToSayRndAutoNoForce' is unclear and overly long. Consider using a more descriptive name that clearly indicates its purpose.
DisplayThinkToSayRndAutoNoForce("API调用失败".Translate() + $",{str}\n{e}"); //, GraphCore.Helper.SayType.Serious);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(chatvpet): 解决工作控制功能的线程冲突问题
问题描述:
当通过插件API调用
ToolStopWork或ToolSleep时,因非UI线程直接操作WPF控件,抛出InvalidOperationException修复方案:
Dispatcher.Invoke封装工作停止和睡眠功能的UI操作影响模块: