Ejemplo n.º 1
0
            /// <summary>
            /// Reject the linked <see cref="Promises.Promise"/> with <paramref name="reason"/>.
            /// </summary>
            public void Reject <TReject>(TReject reason)
            {
                if (!IsValid)
                {
                    throw new InvalidOperationException("Deferred.Reject: instance is not valid.", Internal.GetFormattedStacktrace(1));
                }

                var promise = Promise;

                ValidateOperation(promise, 1);

                if (State == State.Pending)
                {
                    Promise.CancelCallbacks();
                    promise.RejectDirect(ref reason, 1);
                }
                else
                {
                    Internal.AddRejectionToUnhandledStack(reason, null);
                    Manager.LogWarning("Deferred.Reject - Deferred is not in the pending state.");
                }
            }