Browse Source

Add an overload for ClassicDesktopStyleApplicationLifetime (#16167)

* add an overload with no parameters for ClassicDesktopStyleApplicationLifetime

* add an overload with no parameters for ClassicDesktopStyleApplicationLifetime

* add a new internal func: Startcore(args)

---------

Co-authored-by: Max Katz <maxkatz6@outlook.com>
pull/16265/head
Easley wang 2 years ago
committed by GitHub
parent
commit
3da2292c6b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 20
      src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs

20
src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs

@ -117,16 +117,30 @@ namespace Avalonia.Controls.ApplicationLifetimes
}
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;

Loading…
Cancel
Save