mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Handle Avalonia app lifetime differently so app doesn't exit when main window closes.
This commit is contained in:
parent
702d7402a1
commit
62fcb60279
@ -45,7 +45,7 @@ namespace Remotely.Desktop.Linux
|
||||
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
BuildAvaloniaApp().Start(AppMain, args);
|
||||
});
|
||||
|
||||
while (App.Current is null)
|
||||
@ -85,6 +85,12 @@ namespace Remotely.Desktop.Linux
|
||||
}
|
||||
}
|
||||
|
||||
private static void AppMain(Application app, string[] args)
|
||||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
app.Run(cts.Token);
|
||||
}
|
||||
|
||||
private static void BuildServices()
|
||||
{
|
||||
var serviceCollection = new ServiceCollection();
|
||||
|
||||
@ -15,7 +15,7 @@ namespace Remotely.Desktop.Linux.Services
|
||||
{
|
||||
public async Task<bool> PromptForAccess(string requesterName, string organizationName)
|
||||
{
|
||||
var result = await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
return await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
var promptWindow = new PromptForAccessWindow();
|
||||
var viewModel = promptWindow.DataContext as PromptForAccessWindowViewModel;
|
||||
@ -28,14 +28,19 @@ namespace Remotely.Desktop.Linux.Services
|
||||
viewModel.OrganizationName = organizationName;
|
||||
}
|
||||
|
||||
var isOpen = true;
|
||||
promptWindow.Closed += (sender, arg) =>
|
||||
{
|
||||
isOpen = false;
|
||||
};
|
||||
promptWindow.Show();
|
||||
await TaskHelper.DelayUntilAsync(() => !promptWindow.IsVisible, TimeSpan.MaxValue);
|
||||
|
||||
while (isOpen)
|
||||
{
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
return viewModel.PromptResult;
|
||||
});
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user