Ejemplo n.º 1
0
        protected override void SetupSyncContext(int maxParallelThreads)
        {
            var tcs    = new TaskCompletionSource <SynchronizationContext>();
            var thread = new Thread(() =>
            {
                try
                {
                    AvaloniaApp.RegisterDependencies();

                    AvaloniaApp
                    .BuildAvaloniaApp()
                    .AfterSetup(_ =>
                    {
                        tcs.SetResult(SynchronizationContext.Current);
                    })
                    .StartWithClassicDesktopLifetime(new string[0]);
                }
                catch (Exception e)
                {
                    tcs.SetException(e);
                }
            })
            {
                IsBackground = true
            };

            thread.Start();

            SynchronizationContext.SetSynchronizationContext(tcs.Task.Result);
        }