/// <summary> /// Execute the promise that can be rejected. /// </summary> /// <param name="promise">The function to run.</param> /// <param name="onQueue">The queue to execute on.</params> /// <param name="delay">The delay in milliseconds to /// delay the execution.</param> /// <returns>The promise handle.</returns> public Promise( Action <Action <T>, Action <Exception> > promise, IPromiseQueue onQueue = null, int delay = 0 ) : this(onQueue) { Queue.Run( (ValueTuple <Action <T>, Action <Exception> > actions) => { var(fulfill, reject) = actions; try { promise(fulfill, reject); } catch (Exception e) { reject(e); } }, (Fulfill, Reject), delay ); }
/// <summary> /// Creates a new pending promise. /// </summary> /// <param name="queue">The queue to run the action on.</param> internal Promise(IPromiseQueue queue = null) { Queue = queue ?? DefaultQueue; }