Esempio n. 1
0
 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();
         }
     }
 }
Esempio n. 2
0
 /// <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);
 }
Esempio n. 3
0
        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;
            });
        }
Esempio n. 4
0
 public IPromise <D, F, P> Always(Action <State, D, F> callback)
 {
     return(promise.Always(callback));
 }