Пример #1
0
        public static void RunInCurrentStackframe([NotNull] Lifetime lifetime, [NotNull] string name, Action <SingleThreadScheduler> beforeStart = null)
        {
            var res = new SingleThreadScheduler(name, new ActionQueue(lifetime))
            {
                Thread = Thread.CurrentThread
            };

            beforeStart?.Invoke(res);

            res.Run();
        }
Пример #2
0
        public static SingleThreadScheduler RunOnSeparateThread([NotNull] Lifetime lifetime, [NotNull] string name, Action <SingleThreadScheduler> beforeStart = null)
        {
            var res    = new SingleThreadScheduler(name, new ActionQueue(lifetime));
            var thread = new Thread(() => res.Run())
            {
                Name = name
            };

            res.Thread = thread;

            beforeStart?.Invoke(res);

            thread.Start();
            return(res);
        }