-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (44 loc) · 1.48 KB
/
Program.cs
File metadata and controls
52 lines (44 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace FIXSniff;
public partial class App : Application {
public override void Initialize() {
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted() {
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
desktop.MainWindow = new MainWindow();
// Handle shutdown gracefully to avoid D-Bus exceptions
desktop.ShutdownRequested += OnShutdownRequested;
}
base.OnFrameworkInitializationCompleted();
}
private void OnShutdownRequested(object? sender, ShutdownRequestedEventArgs e) {
// Give time for cleanup
try {
Task.Delay(100).Wait();
} catch {
// Ignore any cleanup exceptions
}
}
}
public class Program {
public static void Main(string[] args) {
try {
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
} catch (TaskCanceledException) {
// Ignore D-Bus cleanup exceptions on Linux
} catch (Exception ex) when (ex.Message.Contains("DBus")) {
// Ignore D-Bus related exceptions during shutdown
}
}
public static AppBuilder BuildAvaloniaApp() => AppBuilder
.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
;
}