Beispiel #1
0
        public static IObservable <T> FromCoroutine <T>(Func <IObserver <T>, CancellationToken, IEnumerator> coroutine)
        {
            return(Observable.Create <T>(observer =>
            {
                var cancel = new BooleanDisposable();

                UnityMainThreadDispatcher.SendStartCoroutine(coroutine(observer, new CancellationToken(cancel)));

                return cancel;
            }));
        }
            public IDisposable Schedule(TimeSpan dueTime, Action action)
            {
                var d    = new BooleanDisposable();
                var time = Scheduler.Normalize(dueTime);

                UnityMainThreadDispatcher.SendStartCoroutine(DelayAction(time, () =>
                {
                    if (!d.IsDisposed)
                    {
                        action();
                    }
                }, d));

                return(d);
            }