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

            return(MainThreadDispatcher.StartCoroutine(WhenAllCore(coroutines)));
        }
Exemplo n.º 3
0
 public static IObservable <bool> EveryApplicationFocus()
 {
     return(MainThreadDispatcher.OnApplicationFocusAsObservable().AsObservable());
 }
Exemplo n.º 4
0
 /// <summary>publish OnNext(Unit) and OnCompleted() on application quit.</summary>
 public static IObservable <Unit> OnceApplicationQuit()
 {
     return(MainThreadDispatcher.OnApplicationQuitAsObservable().Take(1));
 }
Exemplo n.º 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));
                    }
                }
            }
Exemplo n.º 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)));
 }
Exemplo n.º 7
0
 public MainThreadScheduler()
 {
     MainThreadDispatcher.Initialize();
     scheduleAction = new Action <object>(Schedule);
 }
Exemplo n.º 8
0
 public void ScheduleQueueing <T>(ICancelable cancel, T state, Action <T> action)
 {
     MainThreadDispatcher.StartEndOfFrameMicroCoroutine(ImmediateAction(state, action, cancel));
 }
Exemplo n.º 9
0
 public EndOfFrameMainThreadScheduler()
 {
     MainThreadDispatcher.Initialize();
 }
Exemplo n.º 10
0
 public FixedUpdateMainThreadScheduler()
 {
     MainThreadDispatcher.Initialize();
 }
Exemplo n.º 11
0
 public void ScheduleQueueing <T>(ICancelable cancel, T state, Action <T> action)
 {
     MainThreadDispatcher.Post(QueuedAction <T> .Instance, Tuple.Create(cancel, state, action));
 }