private static UIThreadHelper Create() { UIThreadHelper uiThreadHelper = new UIThreadHelper(); ManualResetEventSlim initialized = new ManualResetEventSlim(); AppDomain.CurrentDomain.DomainUnload += uiThreadHelper.Destroy; AppDomain.CurrentDomain.ProcessExit += uiThreadHelper.Destroy; // We want to maintain an application on a single STA thread // set Background so that it won't block process exit. Thread thread = new Thread(uiThreadHelper.RunMainThread) { Name = "WPF Dispatcher Thread" }; thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(initialized); initialized.Wait(); uiThreadHelper.Invoke(() => { uiThreadHelper._thread = thread; uiThreadHelper._syncContext = SynchronizationContext.Current; uiThreadHelper._taskScheduler = new ControlledTaskScheduler(uiThreadHelper._syncContext); }); return(uiThreadHelper); }
public BlockingLoopSynchronizationContext(UIThreadHelper threadHelper, SynchronizationContext innerSynchronizationContext) { _threadHelper = threadHelper; _innerSynchronizationContext = innerSynchronizationContext; }
public BlockingLoopSynchronizationContext(UIThreadHelper threadHelper) { _threadHelper = threadHelper; }