Browse Source

Fix crashes in headless memory benchmark

pull/8105/head
Nikita Tsukanov 4 years ago
parent
commit
62571a69b6
  1. 10
      samples/ControlCatalog.NetCore/Program.cs

10
samples/ControlCatalog.NetCore/Program.cs

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

Loading…
Cancel
Save