diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs index e5ae883d5e..df7ae67ef4 100644 --- a/samples/ControlCatalog.NetCore/Program.cs +++ b/samples/ControlCatalog.NetCore/Program.cs @@ -56,10 +56,16 @@ namespace ControlCatalog.NetCore .UseHeadless(new AvaloniaHeadlessPlatformOptions { UseHeadlessDrawing = true, - UseComposition = false + UseComposition = true }) .AfterSetup(_ => { + static Task LowPriorityDelay(int ms) + { + return Task.Delay(ms).ContinueWith(_ => + Dispatcher.UIThread.InvokeAsync(() => { }, DispatcherPriority.Background)) + .Unwrap(); + } DispatcherTimer.RunOnce(async () => { var window = ((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime) @@ -71,7 +77,7 @@ namespace ControlCatalog.NetCore continue; Console.WriteLine("Selecting " + page.Header); tc.SelectedItem = page; - await Task.Delay(50); + await LowPriorityDelay(20); } Console.WriteLine("Selecting the first page"); tc.SelectedItem = tc.Items.OfType().First();