This commit resolves multiple related issues with the Options dialog that caused freezing, crashes, and slow performance:
**Problem 1: Infinite Recursive Loop**
- Symptom: Options dialog would freeze when navigating between pages
- Cause: LstOptionPages_SelectedIndexChanged event handler triggering itself infinitely
- Fix: Added _isHandlingSelectionChange guard flag to prevent recursive calls
**Problem 2: Disposed Object Exception**
- Symptom: "Cannot access a disposed object" error after SSH connection workflow
- Cause: Static FrmOptions instance was disposed but still referenced
- Fix: Enhanced OptionsWindow.LoadOptionsForm() to detect disposal before use
- Fix: Added FrmMain.RecreateOptionsForm() to recreate disposed forms transparently
**Problem 3: Index Out of Range**
- Symptom: "index must be less than 0" when accessing empty lstOptionPages
- Cause: SetActivatedPage() tried to access Items[0] when collection was empty
- Fix: Added bounds checking before accessing lstOptionPages.Items
**Problem 4: NullReferenceException in OptionsPages**
- Symptom: NullReferenceException in LoadRegistrySettings() across all pages
- Cause: pageRegSettingsInstance was null when registry settings didn't exist
- Fix: Added null checks and default instance creation in 8 OptionsPages
**Problem 5: Slow Page Loading on Recreation**
- Symptom: Second Options dialog open showed staggered page loading (~2.2 seconds)
- Cause: Application.Idle async pattern loaded pages one-by-one
- Fix: Replaced async loading with synchronous batch loading using BeginUpdate/EndUpdate
**Files Modified:**
- mRemoteNG/UI/Forms/frmOptions.cs
- mRemoteNG/UI/Window/OptionsWindow.cs
- mRemoteNG/UI/Forms/frmMain.cs
- mRemoteNG/UI/Forms/OptionsPages/StartupExitPage.cs
- mRemoteNG/UI/Forms/OptionsPages/NotificationsPage.cs
- mRemoteNG/UI/Forms/OptionsPages/AppearancePage.cs
- mRemoteNG/UI/Forms/OptionsPages/SecurityPage.cs
- mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.cs
- mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.cs
- mRemoteNG/UI/Forms/OptionsPages/TabsPanelsPage.cs
- mRemoteNG/UI/Forms/OptionsPages/UpdatesPage.cs
**Additional Changes:**
- Replaced all Debug.WriteLine with Logger.Instance.Log for consistent logging
- Added comprehensive debug logging throughout Options form lifecycle
- Improved defensive programming with guard flags and validation checks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixes#2971
This fix addresses the issue where RDP connections with "Automatic resize"
enabled weren't resizing the remote desktop when users manually dragged
window edges - only when changing window states (Maximize/Restore).
Changes:
- RdpProtocol8.cs: Fixed resize logic to use InterfaceControl.Size instead
of Control.Size, added 300ms debounce to reduce flickering, and registered
ResizeEnd event handler
- RdpProtocol9.cs: Added null safety checks in UpdateSessionDisplaySettings
- NotificationPanelMessageWriter.cs: Added exception handling for shutdown
scenarios to prevent InvalidAsynchronousStateException
- RdpProtocol8ResizeTests.cs: Added 12 comprehensive unit tests covering
all resize scenarios including debounce mechanism
- TabColorConverterTests.cs: Added missing System namespace import
The fix works for all RDP versions (8, 9, 10, 11) through inheritance.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>