public static ActionDispatcherSchedulerHandle StartOnNewThread() { ActionDispatcherSchedulerHandle res = null; // ReSharper disable once AccessToDisposedClosure using (var resetEvent = new ManualResetEvent(false)) { new Thread(o => BotServices.RunDispatcher(d => { res = new ActionDispatcherSchedulerHandle(); resetEvent.Set(); })) {IsBackground = true}.Start(); resetEvent.WaitOne(); } return res; }
public static ActionDispatcherSchedulerHandle StartOnNewThread() { ActionDispatcherSchedulerHandle res = null; // ReSharper disable once AccessToDisposedClosure using (var resetEvent = new ManualResetEvent(false)) { new Thread(o => BotServices.RunDispatcher(d => { res = new ActionDispatcherSchedulerHandle(); resetEvent.Set(); })) { IsBackground = true }.Start(); resetEvent.WaitOne(); } return(res); }
internal static ISchedulerHandle GetOrCreateScheduler() { // If the current SynchronizationContext is not set, create a new ActionThread return(GetScheduler() ?? ActionDispatcherSchedulerHandle.StartOnNewThread()); }