Ensures task completion before resource disposal#20
Conversation
Waits for mouse hook and event processing tasks to complete before disposing resources during shutdown. This prevents potential resource contention and ensures a clean shutdown. Adds logging for task completion and timeout scenarios.
There was a problem hiding this comment.
Pull request overview
This PR enhances the Dispose method in MainViewModel to ensure that background tasks complete before disposing underlying resources. It adds synchronous waiting with timeout handling for two background tasks (_updateMouseHookRectsLoopTask and _mouseEventProcessingLoopTask) that process mouse events, along with comprehensive logging for completion and error scenarios.
Key Changes:
- Adds task completion waiting with 5-second timeouts before disposing resources
- Implements exception handling for
OperationCanceledExceptionand other errors during task shutdown - Suppresses VSTHRD002 warning with justification for synchronous waiting in Dispose context
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* Initial plan * Extract duplicated task waiting logic into WaitForTaskCompletion helper method Co-authored-by: magicxor <8275793+magicxor@users.noreply.github.com> * Update WinSyncScroll/ViewModels/MainViewModel.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: magicxor <8275793+magicxor@users.noreply.github.com> Co-authored-by: Ilia Burakov <magicxor@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Waits for mouse hook and event processing tasks to complete
before disposing resources during shutdown. This prevents
potential resource contention and ensures a clean shutdown.
Adds logging for task completion and timeout scenarios.