/// <summary> /// EveryLateUpdate calls from MainThreadDispatcher's OnLateUpdate. /// </summary> public static IObservable <long> EveryLateUpdate() { return(MainThreadDispatcher.LateUpdateAsObservable().Scan(-1L, (x, y) => x + 1)); }
public static Coroutine WhenAll(IEnumerable <LazyTask> tasks) { var coroutines = tasks.Select(x => x.Start()).ToArray(); return(MainThreadDispatcher.StartCoroutine(WhenAllCore(coroutines))); }
public static IObservable <bool> EveryApplicationFocus() { return(MainThreadDispatcher.OnApplicationFocusAsObservable().AsObservable()); }
/// <summary>publish OnNext(Unit) and OnCompleted() on application quit.</summary> public static IObservable <Unit> OnceApplicationQuit() { return(MainThreadDispatcher.OnApplicationQuitAsObservable().Take(1)); }
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)); } } }
/// <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)); }