Conversation
|
Thanks for this @Gillibald. This is the same as #1617 right? Next time could you squash your commits and force push instead of creating a new PR? It's best to keep the conversation in one PR. Will review this shortly. |
|
Yes it is the same. Just didn't know how to remove the merge commits. This will not happen again in the future. Now i know how to sync my fork properly. |
There was a problem hiding this comment.
Hmm, now if i set this in ControlCatalog.Desktop:
BuildAvaloniaApp().SetExitMode(ExitMode.OnMainWindowClose).Start<MainWindow>();
The application doesn't appear to start.
Edit: Hmm ignore that, it seems to be working now, not sure what was happening...
src/Avalonia.Controls/Application.cs
Outdated
|
|
||
| _mainLoopCancellationTokenSource = new CancellationTokenSource(); | ||
|
|
||
| Dispatcher.UIThread.InvokeAsync( |
There was a problem hiding this comment.
Why does this need to be done via an invoke?
There was a problem hiding this comment.
I haven't found a better solution to show the main window and start up the main loop. The invoke queues the action for execution and gets executed when the main loop runs.
There was a problem hiding this comment.
I've tried changing this to:
mainWindow.Show();
MainWindow = mainWindow;
Dispatcher.UIThread.MainLoop(_mainLoopCancellationTokenSource.Token);
And it seems to work. What am I missing?
There was a problem hiding this comment.
If everything works its fine. Not sure about side effects. My solution only runs after the main loop is running. Maybe show does the same. At some point something has to be invoked on the main thread. Is it possible to call run on a different thread or even Window.Show? My solution would avoid that issue.
There was a problem hiding this comment.
Just tried what you did and it didn't work. My approach always runs. Don't know why yours work on your environment.
There was a problem hiding this comment.
Have you tried it with Skia or Direct2D1? Yours works with Skia but not with Direct2D1 on my machine.
There was a problem hiding this comment.
I tried it with Win32/D2D but it also works with skia here. Strange that it doesn't work with D2D on your machine, I don't see how the rendering backend would affect whether a window gets shown or not - that should depend on the windowing backend.
It's also strange because this is how it works on master - Window.Show is called from AppBuilderBase.Start before the main loop is started.
There was a problem hiding this comment.
Dont understand it either has probably something to do with the. net runtime. With .Net Core I dont need invoke. Will remove the invoke call and just hope others don't have the problem.
|
|
||
| namespace Avalonia | ||
| { | ||
| public enum ExitMode |
There was a problem hiding this comment.
Could you add some XML documentation to this enum?
There was a problem hiding this comment.
Will add some comments
…ibald/Avalonia into feature/ApplicationExitMode
|
Thanks @Gillibald ! |
This PR introduces a way to control when the application exits. You can either let the application exit explicitly or implicitly. Furthermore you can now access the main window and open Windows under the current application instance.
The current state calls exit when the main window was closed and there is no way to control this behavior
You are able to control when the application exits.
In the past all open windows where stored under Window and moved to Application with these changes. A ExitMode property was added to application and a SetExitMode method was added to the AppBuilder.
Checklist:
See #1565