Conversation
- Add public StartListen() method to resume log subscription - Add public StopListen() method to stop log subscription - Add _isListening state tracking to prevent duplicate subscriptions - Refactor _OnLoaded to use StartListen() method - Refactor _Dispose to use StopListen() method - Enhance pause functionality to use StopListen/StartListen for better performance - Remove pause check from subscription callback since pause now stops subscription completely This solves the issue where NLogViewer stops working when undocked from docking systems like RadDocking and doesn't resume when docked again. Users can now call StartListen() to resume logging after docking operations.
… traversal - Updated method documentation to clarify UID-based element finding - Implemented recursive approach with HashSet for cycle detection - Improved search logic for both visual and logical trees - Removed unused GetChildObjects method - Enhanced performance and reliability of element discovery
- Added comment explaining the use case for parent window hook - Clarifies behavior when NLogViewer is used in TabControl scenarios - Prevents premature subscription disposal when switching TabItems
- Add comprehensive documentation for StartListen() and StopListen() methods - Explain the root cause: Unloaded event triggers subscription disposal when undocking - Clarify that StartListen() must be called in DockChanged event handler - Reference Issue #90 and explain the docking system subscription management problem - Provide practical usage examples for docking scenarios
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 subscription disposal when undocking the viewer parent container
Overview
This PR addresses Issue #90 by implementing proper subscription lifecycle management for NLogViewer controls used in docking systems.
Problem
When NLogViewer controls are used in docking systems, moving controls between different parent windows causes subscription leaks and improper disposal. The root cause is that when undocking occurs, the
Unloadedevent is triggered, which automatically disposes the subscription, leaving the control unable to receive log events.Solution
1. Added Manual Subscription Control Methods
StartListen(): Starts listening for log events by subscribing to the cache targetStopListen(): Stops listening for log events by disposing the subscription2. Enhanced Parent Window Management
FindChildByUidmethod with cycle detection and improved tree traversal3. Comprehensive Documentation
Key Features
StartListen()when loaded andStopListen()when properly disposedUsage Example
Technical Details
Files Changed
src/NLogViewer/NLogViewer.xaml.cs- Added StartListen/StopListen methods and enhanced disposal logicsrc/NLogViewer/Extensions/DependencyObjectExtensions.cs- Improved FindChildByUid methodREADME.md- Added comprehensive documentationTesting
Breaking Changes
None - this is a backward-compatible enhancement.
Related Issues
Commits
79fcfbb- Add StartListen/StopListen methods to fix docking system issue173dac7- Refactor FindChildByUid method with cycle detection and improved tree traversald4e1c72- Add documentation for parent window subscription disposalbbd85ad- Add documentation for StartListen/StopListen methods and Issue Susbscription dispose when undock the viewer parent container. #90