public HiveMPPromiseMainThreadReturnHandler(HiveMPPromiseDelegate <T> task, Action <T> resolve, Action <Exception> reject) { _resolve = resolve; _reject = reject; StartCoroutine(WaitUntilResult()); ThreadPool.QueueUserWorkItem(_ => { try { task((result) => { _t = result; _hasT = true; }, (ex) => { _ex = ex; }); } catch (Exception ex) { _ex = ex; } }); }
/// <summary> /// Creates a new C# promise with no result value. /// </summary> /// <param name="handler">The callback handler to execute with this promise.</param> public HiveMPPromise(HiveMPPromiseDelegate handler) { _handler = handler; _then = new List <Action>(); _catch = new List <Action <Exception> >(); }