public static StartCoroutine ( IEnumerator routine ) : |
||
routine | IEnumerator | |
리턴 |
public static CoroutineAsyncBridge Start <T>(T awaitTarget) { var bridge = new CoroutineAsyncBridge(); MainThreadDispatcher.StartCoroutine(bridge.Run(awaitTarget)); return(bridge); }
public static IObservable <T> DelayFrame <T>(this IObservable <T> source, int frameCount) { if (frameCount < 0) { throw new ArgumentOutOfRangeException("frameCount"); } return(Observable.Create <T>(observer => { var cancel = new BooleanDisposable(); source.Materialize().Subscribe(x => { if (x.Kind == NotificationKind.OnError) { observer.OnError(x.Exception); cancel.Dispose(); return; } MainThreadDispatcher.StartCoroutine(DelayFrameCore(() => x.Accept(observer), frameCount, cancel)); }); return cancel; })); }
public static Coroutine StartCoroutine(IEnumerator routine) { MainThreadDispatcher mainThreadDispatcher = MainThreadDispatcher.Instance; if (mainThreadDispatcher != null) { return(mainThreadDispatcher.StartCoroutine(routine)); } return(null); }
public static IObservable <T> FromCoroutine <T>(Func <IObserver <T>, CancellationToken, IEnumerator> coroutine) { return(Observable.Create <T>(observer => { var cancel = new BooleanDisposable(); MainThreadDispatcher.StartCoroutine(coroutine(observer, new CancellationToken(cancel))); return cancel; })); }
public IDisposable Schedule <TState>(TState state, TimeSpan dueTime, Func <IScheduler, TState, IDisposable> action) { var d = new SingleAssignmentDisposable(); MainThreadDispatcher.StartCoroutine(DelayAction(dueTime, () => { if (!d.IsDisposed) { d.Disposable = action(this, state); } })); return(d); }
private void Awake() { if (MainThreadDispatcher.instance == null) { MainThreadDispatcher.instance = this; MainThreadDispatcher.mainThreadToken = new object(); MainThreadDispatcher.initialized = true; this.updateMicroCoroutine = new MicroCoroutine(delegate(Exception ex) { this.unhandledExceptionCallback(ex); }); this.fixedUpdateMicroCoroutine = new MicroCoroutine(delegate(Exception ex) { this.unhandledExceptionCallback(ex); }); this.endOfFrameMicroCoroutine = new MicroCoroutine(delegate(Exception ex) { this.unhandledExceptionCallback(ex); }); MainThreadDispatcher.StartCoroutine(this.RunUpdateMicroCoroutine()); MainThreadDispatcher.StartCoroutine(this.RunFixedUpdateMicroCoroutine()); MainThreadDispatcher.StartCoroutine(this.RunEndOfFrameMicroCoroutine()); UnityEngine.Object.DontDestroyOnLoad(base.gameObject); } else if (this != MainThreadDispatcher.instance) { if (MainThreadDispatcher.cullingMode == MainThreadDispatcher.CullingMode.Self) { global::Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Removing myself..."); MainThreadDispatcher.DestroyDispatcher(this); } else if (MainThreadDispatcher.cullingMode == MainThreadDispatcher.CullingMode.All) { global::Debug.LogWarning("There is already a MainThreadDispatcher in the scene. Cleaning up all excess dispatchers..."); MainThreadDispatcher.CullAllExcessDispatchers(); } else { global::Debug.LogWarning("There is already a MainThreadDispatcher in the scene."); } } }
public static void SendStartCoroutine(IEnumerator routine) { if (MainThreadDispatcher.mainThreadToken != null) { MainThreadDispatcher.StartCoroutine(routine); } else { MainThreadDispatcher mainThreadDispatcher = MainThreadDispatcher.Instance; if (mainThreadDispatcher != null) { mainThreadDispatcher.queueWorker.Enqueue(delegate { MainThreadDispatcher mainThreadDispatcher2 = MainThreadDispatcher.Instance; if (mainThreadDispatcher2 != null) { mainThreadDispatcher2.StartCoroutine_Auto(routine); } }); } } }
public static void SendStartCoroutine(IEnumerator routine) { if (MainThreadDispatcher.mainThreadToken != null) { MainThreadDispatcher.StartCoroutine(routine); } else { MainThreadDispatcher mainThreadDispatcher = MainThreadDispatcher.Instance; if (!MainThreadDispatcher.isQuitting && !object.ReferenceEquals(mainThreadDispatcher, null)) { mainThreadDispatcher.queueWorker.Enqueue(delegate(object _) { MainThreadDispatcher mainThreadDispatcher2 = MainThreadDispatcher.Instance; if (mainThreadDispatcher2 != null) { mainThreadDispatcher2.StartCoroutine(routine); } }, null); } } }
/// <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 static Coroutine WhenAll(IEnumerable <LazyTask> tasks) { var coroutines = tasks.Select(x => x.Start()).ToArray(); return(MainThreadDispatcher.StartCoroutine(WhenAllCore(coroutines))); }
public static Coroutine WhenAll(IEnumerable <LazyTask> tasks) { Coroutine[] coroutines = Enumerable.ToArray <Coroutine>(Enumerable.Select <LazyTask, Coroutine>(tasks, (LazyTask x) => x.Start())); return(MainThreadDispatcher.StartCoroutine(LazyTask.WhenAllCore(coroutines))); }
public static Coroutine WhenAll(IEnumerable <LazyTask> tasks) { Coroutine[] coroutines = (from x in tasks select x.Start()).ToArray(); return(MainThreadDispatcher.StartCoroutine(WhenAllCore(coroutines))); }