gui-cs / Terminal.Gui

Cross Platform Terminal UI toolkit for .NET
MIT License
9.67k stars 689 forks source link

Something in 1.13 broke centering child windows #2775

Closed dodexahedron closed 1 year ago

dodexahedron commented 1 year ago

Describe the bug On 1.12.1, a child window added to another window at run-time, with X and Y set to Dim.Center() is displayed in the center of the parent Window that it is added to.

In 1.13.x, the child window is placed at 0,0 when shown. This occurs on Ubuntu 23.04 and on Windows 11 in PowerShell. If the terminal is resized down and then to a size larger than the child window, it then centers itself.

I set a breakpoint to see what was going on.

In 1.13.x, the superview of the child has 0 width and height, even though the parent Window itself has the expected dimensions. In 1.12.x, the superview of the child has the expected dimensions of the parent window.

Note that both of these Windows were created using the TerminalGuiDesigner tool.

The code used to add the child to the parent is just three lines (edited for verbosity):

//Elsewhere in the parent window class:
ChildWindowClass _childWindowAsAFieldBelongingToParentWindow = null;

//Function called by any means to create and show the child for the first time:
public void FunctionThatAddsTheChildWindow()
{
        _childWindowAsAFieldBelongingToParentWindow ??= new( );
        Add( _childWindowAsAFieldBelongingToParentWindow );
        ShowChild( _childWindowAsAFieldBelongingToParentWindow );
}

To Reproduce Steps to reproduce the behavior:

Using 1.13.X (seems broken for any version of 1.13):

  1. Create a Window with width and height = Dim.Fill(0)
  2. Create a Window with explicit dimensions (any will do, so long as they're smaller than the terminal), and with X and Y = Dim.Center().
  3. Add that second Window to the first Window, and show it.
  4. The child window will be at 0,0,

Expected behavior The child window should be shown positioned at the center of the parent window it was added to, as in 1.12.

Desktop (please complete the following information):

Started happening after updating to the 1.13 release series. No code changes were made.

dodexahedron commented 1 year ago

Just saw your update.

I had tested the original commit you made a while back, and it fixed the issue for my usage.

Did you make further changes?

If so, I'll gladly check again when I finish what I'm currently working on.

BDisp commented 1 year ago

Just saw your update.

I had tested the original commit you made a while back, and it fixed the issue for my usage.

Did you make further changes?

Yes, mostly fixes some bugs with Mdi Container where the child was clear the old position when it's drawing in the new position, leaving a trace behind. I added a lot of tests that proves that all the changes works. Test the CenteredWindowInsideWindow and the CenteredWindowInsideMdiContainerWindow that despite of the similarity behavior they are coded differently.

If so, I'll gladly check again when I finish what I'm currently working on.

Thanks.

dodexahedron commented 1 year ago

Cool. I don't know for sure if I had ever hit that issue, though I may have one time that I just thought it was caused by Windows, when the system was under high CPU load from something else.

I'll check this out later this evening (UTC-7) if I don't forget. 😅

dodexahedron commented 1 year ago

Ah yes. Looking at the PR, it looks like you implemented a much more thorough and likely more efficient fix than the initial fix, which was just adding the call to LayoutSubviews(), which is what I'm currently using as a workaround.

I'll test this in a few minutes and let you know how it went when I'm done.

dodexahedron commented 1 year ago

I checked out BDisp/v1_centering-child-window-fix_2775, compiled in Release configuration, and used that with my code.

I removed the call to LayoutSubviews() I had added to my code and otherwise left it exactly as it currently exists in the siaz-1.1 branch.

The windows center correcly.

However, upon exiting, there is now a pause and then I get a very large stack trace that is being truncated at the top, so I do not know what the exception is. It's not being handed to my exception handler, so it also doesn't get logged by nlog.

All I'm able to see of the stack trace is:

at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Application.ProcessKeyEvent(Terminal.Gui.KeyEvent)
   at Terminal.Gui.WindowsDriver.ProcessInput(InputRecord)
   at Terminal.Gui.WindowsDriver.<PrepareToRun>b__38_0(InputRecord)
   at Terminal.Gui.WindowsMainLoop.Terminal.Gui.IMainLoopDriver.MainIteration()
   at Terminal.Gui.MainLoop.MainIteration()
   at Terminal.Gui.Application.RunMainLoopIteration(RunState ByRef, Boolean, Boolean ByRef)
   at Terminal.Gui.Application.RunLoop(RunState, Boolean)
   at Terminal.Gui.Application.Run(Terminal.Gui.Toplevel, System.Func`2<System.Exception,Boolean>)
   at Terminal.Gui.Application.Run[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`2<System.Exception,Boolean>, Terminal.Gui.ConsoleDriver, Terminal.Gui.IMainLoopDriver)
   at SnapsInAZfs.ConfigConsole.ConfigConsole.RunConsoleInterface(SnapsInAZfs.Interop.Zfs.ZfsCommandRunner.IZfsCommandRunner)
   at SnapsInAZfs.Program+<Main>d__5.MoveNext()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext(System.Threading.Thread)
   at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()

I think it is an ArgumentException, because Visual Studio's debug pane does show this:

Exception thrown: 'System.ArgumentException' in Terminal.Gui.dll

I know you mentioned I may be doing something wrong with how the windows are being shown, though.

One of the methods that shows a window is here: https://github.com/snapsinazfs/snapsinazfs/blob/master/SnapsInAZfs/ConfigConsole/SnapsInAZfsConfigConsole.cs#L133

Note I do have IsMdiContainer=true on the parent window.\ The child windows do not show if I do not set that.

dodexahedron commented 1 year ago

There may be an infinite loop situation.

I made the font tiny so I'd get more lines in the console and this is the resulting stack trace (still truncated):

   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.View.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Toplevel.ProcessHotKey(Terminal.Gui.KeyEvent)
   at Terminal.Gui.Application.ProcessKeyEvent(Terminal.Gui.KeyEvent)
   at Terminal.Gui.WindowsDriver.ProcessInput(InputRecord)
   at Terminal.Gui.WindowsMainLoop.Terminal.Gui.IMainLoopDriver.MainIteration()
   at Terminal.Gui.MainLoop.MainIteration()
   at Terminal.Gui.Application.RunMainLoopIteration(RunState ByRef, Boolean, Boolean ByRef)
   at Terminal.Gui.Application.RunLoop(RunState, Boolean)
   at Terminal.Gui.Application.Run(Terminal.Gui.Toplevel, System.Func`2<System.Exception,Boolean>)
   at Terminal.Gui.Application.Run[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`2<System.Exception,Boolean>, Terminal.Gui.ConsoleDriver, Terminal.Gui.IMainLoopDriver)
   at SnapsInAZfs.ConfigConsole.ConfigConsole.RunConsoleInterface(SnapsInAZfs.Interop.Zfs.ZfsCommandRunner.IZfsCommandRunner)
   at SnapsInAZfs.Program+<Main>d__5.MoveNext()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext(System.Threading.Thread)
   at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
dodexahedron commented 1 year ago

It looks like it may be related to having a hotkey handler subscribed (possibly in conjunction with anything else I might be doing wrong).

In the parent window, I have:

        Application.RootKeyEvent += ApplicationRootKeyEvent;

And that function is:

    private bool ApplicationRootKeyEvent( KeyEvent e )
    {
        if ( !e.IsCtrl )
        {
            return false;
        }

        // ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
        switch ( e.Key & Key.CharMask )
        {
            case Key.g:
            case Key.G:
                globalConfigMenuItem.Action( );
                return true;
            case Key.t:
            case Key.T:
                templateConfigMenuItem.Action( );
                return true;
            case Key.z:
            case Key.Z:
                zfsConfigMenuItem.Action( );
                return true;
        }

        return false;
    }

This is to enable ctrl+g, etc to show/hide the child windows.

If I do not subscribe to the event, I do not encounter the exception on exit. But of course that means my hotkeys don't work.

So there might be something wrong with Terminal.Gui.Toplevel.ProcessHotKey(KeyEvent keyEvent), Terminal.Gui.View.ProcessHotKey(KeyEvent keyEvent) or the way I'm using the event.

It only happens when I use ctrl+q to exit ONLY while a child window is still visible. If I hide the child window first, it doesn't happen, and if I don't show the child window in the first place, it doesn't happen, even if I use ctrl+q to quit.

dodexahedron commented 1 year ago

Update to that:

I added a case for ctrl+q to my handler that unsubscribes the Application.RootKeyEvent handler and returns false, but the loop still occurs in the same situations as before, so I don't think it's my handler, specifically, that's breaking it. At least not by itself.

BDisp commented 1 year ago

@dodexahedron why you don't you use the Application.Init and using the ErrorHandler to bypass that?

Edit: The isMdiContainer must be used to the top app and the child must be added to the Application toplevels with Application.Run(myWindow) and not with Add(myWindow) which will be a subview and not a MdiChild. So, ShowChild and HideChild methods are only valid for a Application.Top that is Application.MdiTop with IsMdiContainer = true and after they are running, never before. I'll submit a PR to your repo without using Mdi Container.