Beispiel #1
0
 /// <summary>
 /// EveryLateUpdate calls from MainThreadDispatcher's OnLateUpdate.
 /// </summary>
 public static IObservable <long> EveryLateUpdate()
 {
     return(MainThreadDispatcher.LateUpdateAsObservable().Scan(-1L, (x, y) => x + 1));
 }
Beispiel #2
0
        public static Coroutine WhenAll(IEnumerable <LazyTask> tasks)
        {
            var coroutines = tasks.Select(x => x.Start()).ToArray();

            return(MainThreadDispatcher.StartCoroutine(WhenAllCore(coroutines)));
        }
Beispiel #3
0
 public static IObservable <bool> EveryApplicationFocus()
 {
     return(MainThreadDispatcher.OnApplicationFocusAsObservable().AsObservable());
 }
Beispiel #4
0
 /// <summary>publish OnNext(Unit) and OnCompleted() on application quit.</summary>
 public static IObservable <Unit> OnceApplicationQuit()
 {
     return(MainThreadDispatcher.OnApplicationQuitAsObservable().Take(1));
 }
Beispiel #5
0
            void RecursiveRun(Action self)
            {
                lock (gate)
                {
                    this.nextSelf = self;
                    if (isDisposed)
                    {
                        return;
                    }
                    if (isStopped)
                    {
                        return;
                    }

                    var current = default(IObservable <T>);
                    var hasNext = false;
                    var ex      = default(Exception);

                    try
                    {
                        hasNext = e.MoveNext();
                        if (hasNext)
                        {
                            current = e.Current;
                            if (current == null)
                            {
                                throw new InvalidOperationException("sequence is null.");
                            }
                        }
                        else
                        {
                            e.Dispose();
                        }
                    }
                    catch (Exception exception)
                    {
                        ex = exception;
                        e.Dispose();
                    }

                    if (ex != null)
                    {
                        stopper.Dispose();
                        observer.OnError(ex);
                        return;
                    }

                    if (!hasNext)
                    {
                        stopper.Dispose();
                        observer.OnCompleted();
                        return;
                    }

                    var source = e.Current;
                    var d      = new SingleAssignmentDisposable();
                    subscription.Disposable = d;

                    if (isFirstSubscribe)
                    {
                        isFirstSubscribe = false;
                        d.Disposable     = source.Subscribe(this);
                    }
                    else
                    {
                        MainThreadDispatcher.SendStartCoroutine(SubscribeAfterEndOfFrame(d, source, this, parent.lifeTimeChecker));
                    }
                }
            }
Beispiel #6
0
 /// <summary>AutoStart observable as coroutine.</summary>
 public static Coroutine StartAsCoroutine <T>(this IObservable <T> source, Action <T> onResult, Action <Exception> onError, CancellationToken cancel = default(CancellationToken))
 {
     return(MainThreadDispatcher.StartCoroutine(source.ToAwaitableEnumerator(onResult, onError, cancel)));
 }
 public MainThreadScheduler()
 {
     MainThreadDispatcher.Initialize();
     scheduleAction = new Action <object>(Schedule);
 }
 public void ScheduleQueueing <T>(ICancelable cancel, T state, Action <T> action)
 {
     MainThreadDispatcher.StartEndOfFrameMicroCoroutine(ImmediateAction(state, action, cancel));
 }
 public EndOfFrameMainThreadScheduler()
 {
     MainThreadDispatcher.Initialize();
 }
 public FixedUpdateMainThreadScheduler()
 {
     MainThreadDispatcher.Initialize();
 }
 public void ScheduleQueueing <T>(ICancelable cancel, T state, Action <T> action)
 {
     MainThreadDispatcher.Post(QueuedAction <T> .Instance, Tuple.Create(cancel, state, action));
 }