Skip to content

Commit 65185c6

Browse files
committed
fix(Avalonia): await CLICommands
Ensures commands like -OCR are run before the MainWindow opens.
1 parent 88b823a commit 65185c6

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

SnapX.Avalonia/App.axaml.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ private static async Task<IClipboard> GetOrCreateClipboardWindowAsync()
488488
}
489489
CancellationTokenSource? _pollingCts = null;
490490

491-
public override void OnFrameworkInitializationCompleted()
491+
// ReSharper disable once AsyncVoidMethod
492+
public override async void OnFrameworkInitializationCompleted()
492493
{
493494
// Crashes must be contained, AT ALL COSTS!
494495
Dispatcher.UIThread.UnhandledException += (s, e) =>
@@ -560,12 +561,9 @@ public override void OnFrameworkInitializationCompleted()
560561
// DebugHelper.Logger.Debug($"Avalonia Args: {desktop.Args}");
561562
try
562563
{
563-
Task.Run(() => SnapX.start(desktop.Args ?? [])).GetAwaiter().GetResult();
564+
SnapX.start(desktop.Args ?? []);
564565
var CLIManager = SnapX.GetCLIManager();
565-
Task.Run(() => CLIManager.UseCommandLineArgs().GetAwaiter().GetResult())
566-
.ConfigureAwait(false)
567-
.GetAwaiter()
568-
.GetResult();
566+
await CLIManager.UseCommandLineArgs();
569567
}
570568
catch (Exception ex)
571569
{

0 commit comments

Comments
 (0)