csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.1 KiB
69 lines
2.1 KiB
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using Avalonia;
|
|
using Avalonia.Skia;
|
|
using Avalonia.Threading;
|
|
|
|
namespace ControlCatalog.NetCore
|
|
{
|
|
static class Program
|
|
{
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
if (args.Contains("--wait-for-attach"))
|
|
{
|
|
Console.WriteLine("Attach debugger and use 'Set next statement'");
|
|
while (true)
|
|
{
|
|
Thread.Sleep(100);
|
|
if (Debugger.IsAttached)
|
|
break;
|
|
}
|
|
}
|
|
BuildAvaloniaApp().Start<MainWindow>();
|
|
return;
|
|
var app = BuildAvaloniaApp().SetupWithoutStarting().Instance;
|
|
var src = new CancellationTokenSource();
|
|
int cnt = 0;
|
|
DispatcherTimer timer = null;
|
|
timer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, delegate
|
|
{
|
|
cnt++;
|
|
Console.WriteLine("Tick " + cnt);
|
|
if (cnt == 3)
|
|
{
|
|
timer.Stop();
|
|
Dispatcher.UIThread.InvokeAsync(() =>
|
|
{
|
|
Console.WriteLine("Invoked");
|
|
src.Cancel();
|
|
});
|
|
}
|
|
});
|
|
timer.Start();
|
|
|
|
app.Run(src.Token);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// This method is needed for IDE previewer infrastructure
|
|
/// </summary>
|
|
public static AppBuilder BuildAvaloniaApp()
|
|
{
|
|
var libraryPath = Path.Combine(Directory.GetCurrentDirectory(),
|
|
"../../src/Avalonia.Native.OSX/build/Avalonia.Native.OSX/Build/Products/Debug/libAvalonia.Native.OSX.dylib");
|
|
|
|
return AppBuilder.Configure<App>().UseAvaloniaNative(libraryPath, opts =>
|
|
{
|
|
opts.UseGpu = true;
|
|
opts.UseDeferredRendering = true;
|
|
}).UseSkia();
|
|
}
|
|
|
|
}
|
|
}
|
|
|