internal static void WaitNoError <T>(this IPromise <T> promise) { if (!SpinWait(promise)) { var mre = new ManualResetEvent(false); promise.Always(() => { mre.Set(); }); if (!promise.IsRejected && !promise.IsResolved) { mre.WaitOne(); } } }
/// <summary> /// Block the current thread waiting for a promise to complete /// </summary> /// <param name="promise">The promise to wait for</param> /// <returns>The resolved value of the promise</returns> public static T Wait <T>(this IPromise <T> promise) { if (!SpinWait(promise)) { var mre = new ManualResetEvent(false); promise.Always(() => { mre.Set(); }); if (!promise.IsRejected && !promise.IsResolved) { mre.WaitOne(); } } return(promise.Value); }
private void OnClick() { if (promise == null || loading) { return; } loading = true; IPromise p = promise(); loadingGroup.SetActive(true); mainGroup.SetActive(false); p.Always(() => { loadingGroup.SetActive(false); mainGroup.SetActive(true); loading = false; }); }
public IPromise <D, F, P> Always(Action <State, D, F> callback) { return(promise.Always(callback)); }