Repository navigation
fix: main window hangs on exit; one progress bar for code generation - #2507
Merged
Merged
Conversation
McpHttpHost.Stop blocked the UI thread on StopAsync while ASP.NET posted a continuation back to that same thread, so the window never closed. Run the teardown on the thread pool. Also give the MCP host the no-op host lifetime already used by the HTTP API server, so SIGTERM and Ctrl+C are no longer swallowed.
The progress window showed 100% after the method preparation loop, then spent seconds in program analysis and printing with no visible change. Split code generation into numbered phases (1/5 to 5/5) sharing one bar with fixed shares, report the program analysis parts and each calling conventions round as steps, and report a step per printed method.
maximilien-noal
requested changes
Nov 12, 2026
| } | ||
| _mcpFileLogger?.Dispose(); | ||
| _mcpFileLogger = null; | ||
| Task.Run(() => DisposeAsync().AsTask()).GetAwaiter().GetResult(); |
Member
There was a problem hiding this comment.
Sync over async and thread pool thread used for a lightweight task (the Task is not CPU bound)
The getAwaiter getResult should be removed, task.Run should be removed. And the Task should be awaited. And the method should be of type async Task. And the caller should be async, and so on (async is viral)
To avoid a continuation on the UI thread SynchronizationContext use .ConfigureAwait(false)
await someTask.ConfigureAwait(false)
Contributor
Author
There was a problem hiding this comment.
As discussed to be done in a separate PR, thanks for the review :)
maximilien-noal
self-requested a review
November 12, 2026 10:06
maximilien-noal
approved these changes
Nov 12, 2026
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.
Summary
McpHttpHost.Stop()onStopAsync().GetAwaiter().GetResult(). Kestrel had already stopped, butGenericWebHostService.StopAsyncposted its continuation to the captured Avalonia UI context, which was the blocked thread: a deadlock.Stop()now runs the teardown on the thread pool.kill -9worked) because the MCP host used the defaultConsoleLifetime. The no-opEmbeddedHostLifetimeof the HTTP API server moves to its own file, and the MCP host uses it too.(1/5)to(5/5)that share one progress bar with fixed shares: preparing methods 0-40%, program analysis 40-90%, printing methods 90-100%. Program analysis reports its 4 parts as steps, and the calling conventions fixed point reports each round so the text changes about every second. Printing reports one step per method. Slow-method lines are nowCode generation: slow method ....Test plan
McpHttpHostTest.Stop_Completes_WhenCallerSynchronizationContextIsBlocked: times out on the old code, passes nowGeneratorProgressTest,DumpProgressTest,DumpProgressReporterTest,DumpProgressViewModelTest(newCodeGenerationPhasesShareOneProgressBar)Spice86.Tests.UI: 79/79; no golden changes