优化日程提醒逻辑:改善内存管理、防重复提醒和可配置提醒间隔 #8
Draft
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.
问题描述
当前的
ReminderTask.cs实现存在几个关键问题:Task.Delay().ContinueWith()创建的任务没有取消机制,可能导致内存中积累大量未完成的任务解决方案
1. 内存管理优化
添加了
CancellationTokenSource来正确管理任务生命周期:2. 优化的事件去重机制
实现了更稳健的基于事件唯一标识的去重系统:
3. 高效的清理机制
Dictionary<string, DateTimeOffset>直接存储提醒时间,避免字符串解析4. 可配置的提醒参数
新增配置选项到
PluginConfig:5. 提升检查精度
6. 增强错误处理
关键改进
向后兼容性
所有更改完全向后兼容:
测试建议
建议测试以下场景:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.