Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an overload for ClassicDesktopStyleApplicationLifetime #16167

Merged
merged 5 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,30 @@ internal void SetupCore(string[] args)
}

public int Start(string[] args)
{
return StartCore(args);
}

/// <summary>
/// Since the lifetime must be set up/prepared with 'args' before executing Start(), an overload with no parameters seems more suitable for integrating with some lifetime manager providers, such as MS HostApplicationBuilder.
/// </summary>
/// <returns>exit code</returns>
public int Start()
{
return StartCore(Args ?? Array.Empty<string>());
}

internal int StartCore(string[] args)
{
SetupCore(args);

_cts = new CancellationTokenSource();

// Note due to a bug in the JIT we wrap this in a method, otherwise MainWindow
// gets stuffed into a local var and can not be GCed until after the program stops.
// this method never exits until program end.
ShowMainWindow();
ShowMainWindow();

Dispatcher.UIThread.MainLoop(_cts.Token);
Environment.ExitCode = _exitCode;
return _exitCode;
Expand Down
Loading