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;
 }
Exemple #2
0
        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);
        }
Exemple #3
0
 internal static ISchedulerHandle GetOrCreateScheduler()
 {
     // If the current SynchronizationContext is not set, create a new ActionThread
     return(GetScheduler() ?? ActionDispatcherSchedulerHandle.StartOnNewThread());
 }