Search Results for

    Show / Hide Table of Contents

    Class Promise<T>

    A promise.

    Inheritance
    System.Object
    FutureBase<T>
    Future<T>
    PromiseBase<T>
    Promise<T>
    Implements
    IPromise
    Inherited Members
    PromiseBase<T>.Id
    PromiseBase<T>.CastAndResolve(Object)
    PromiseBase<T>.Resolve(T)
    PromiseBase<T>.Reject(Exception)
    PromiseBase<T>.ResolveNow<R>(R)
    PromiseBase<T>.RejectNow<R>(Exception)
    PromiseBase<T>.ResolveAsync(T)
    PromiseBase<T>.RejectAsync(Exception)
    PromiseBase<T>.All<R>(Future<R>[])
    PromiseBase<T>.DoAll<R>(Future<R>[], AtomicInteger)
    PromiseBase<T>.ResolveNow()
    PromiseBase<T>.RejectNow(Exception)
    PromiseBase<T>.WrapPromise<R>(Function0<Future<R>>)
    PromiseBase<T>.Process(IPromise, Action1<T>, Action1<Exception>)
    Future<T>.WaitForResult()
    Future<T>.WaitForResult(Int32)
    Future<T>.WaitForPromise()
    Future<T>.WaitForPromise(Int32)
    FutureBase<T>.State
    FutureBase<T>.Result
    FutureBase<T>.Exception
    Namespace: FM.LiveSwitch
    Assembly: FM.LiveSwitch.dll
    Syntax
    public class Promise<T> : PromiseBase<T>, IPromise where T : class
    Type Parameters
    Name Description
    T

    The type of the result.

    Constructors

    Promise()

    Creates a new promise.

    Declaration
    public Promise()

    Promise(Action2<Action1<T>, Action1<Exception>>)

    Creates a promise with a resolve callback and a reject callback.

    Declaration
    public Promise(Action2<Action1<T>, Action1<Exception>> callback)
    Parameters
    Type Name Description
    Action2<Action1<T>, Action1<Exception>> callback

    Methods

    Fail(Action1<Exception>)

    Appends a handler to be executed when the promise is rejected.

    Declaration
    public override Future<T> Fail(Action1<Exception> rejectAction)
    Parameters
    Type Name Description
    Action1<Exception> rejectAction

    The reject action.

    Returns
    Type Description
    Future<T>
    Overrides
    FM.LiveSwitch.Future<T>.Fail(FM.LiveSwitch.Action1<Exception>)

    Fail(Function1<Exception, Future<T>>)

    Appends a handler to be executed when the promise is rejected.

    Declaration
    public override Future<T> Fail(Function1<Exception, Future<T>> rejectFunction)
    Parameters
    Type Name Description
    Function1<Exception, Future<T>> rejectFunction

    The reject function.

    Returns
    Type Description
    Future<T>
    Overrides
    FM.LiveSwitch.Future<T>.Fail(FM.LiveSwitch.Function1<Exception, FM.LiveSwitch.Future<T>>)

    Then(Action1<T>)

    Appends a handler to be executed when the promise is resolved.

    Declaration
    public override Future<T> Then(Action1<T> resolveAction)
    Parameters
    Type Name Description
    Action1<T> resolveAction

    The resolve action.

    Returns
    Type Description
    Future<T>
    Overrides
    FM.LiveSwitch.Future<T>.Then(FM.LiveSwitch.Action1<T>)

    Then(Action1<T>, Action1<Exception>)

    Appends handlers to be executed when the promise is resolved or rejected.

    Declaration
    public override Future<T> Then(Action1<T> resolveAction, Action1<Exception> rejectAction)
    Parameters
    Type Name Description
    Action1<T> resolveAction

    The resolve action.

    Action1<Exception> rejectAction

    The reject action.

    Returns
    Type Description
    Future<T>
    Overrides
    FM.LiveSwitch.Future<T>.Then(FM.LiveSwitch.Action1<T>, FM.LiveSwitch.Action1<Exception>)

    Then<R>(Function1<T, Future<R>>)

    Appends a handler to be executed when the promise is resolved.

    Declaration
    public override Future<R> Then<R>(Function1<T, Future<R>> resolveFunction)
        where R : class
    Parameters
    Type Name Description
    Function1<T, Future<R>> resolveFunction

    The resolve function.

    Returns
    Type Description
    Future<R>
    Type Parameters
    Name Description
    R
    Overrides
    FM.LiveSwitch.Future<T>.Then<R>(FM.LiveSwitch.Function1<T, FM.LiveSwitch.Future<R>>)

    Then<R>(Function1<T, Future<R>>, Action1<Exception>)

    Appends handlers to be executed when the promise is resolved or rejected.

    Declaration
    public override Future<R> Then<R>(Function1<T, Future<R>> resolveFunction, Action1<Exception> rejectAction)
        where R : class
    Parameters
    Type Name Description
    Function1<T, Future<R>> resolveFunction

    The resolve function.

    Action1<Exception> rejectAction

    The reject action.

    Returns
    Type Description
    Future<R>
    Type Parameters
    Name Description
    R
    Overrides
    FM.LiveSwitch.Future<T>.Then<R>(FM.LiveSwitch.Function1<T, FM.LiveSwitch.Future<R>>, FM.LiveSwitch.Action1<Exception>)

    Wrap(Action0)

    Creates a promise and resolves it after invoking a callback action, or rejects it if an exception is thrown.

    Declaration
    public static Future<object> Wrap(Action0 callbackAction)
    Parameters
    Type Name Description
    Action0 callbackAction

    The callback action.

    Returns
    Type Description
    Future<System.Object>

    Wrap<R>(Function0<R>)

    Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown.

    Declaration
    public static Future<R> Wrap<R>(Function0<R> callbackFunction)
        where R : class
    Parameters
    Type Name Description
    Function0<R> callbackFunction

    The callback function.

    Returns
    Type Description
    Future<R>
    Type Parameters
    Name Description
    R

    WrapAsync(Action0)

    Creates a promise and resolves it after invoking a callback action, or rejects it if an exception is thrown. The callback is always dispatched to the background.

    Declaration
    public static Future<object> WrapAsync(Action0 callbackAction)
    Parameters
    Type Name Description
    Action0 callbackAction

    The callback action.

    Returns
    Type Description
    Future<System.Object>

    WrapAsync<R>(Function0<R>)

    Creates a promise and resolves it using the result from a callback function, or rejects it if an exception is thrown. The callback is always dispatched to the background.

    Declaration
    public static Future<R> WrapAsync<R>(Function0<R> callbackFunction)
        where R : class
    Parameters
    Type Name Description
    Function0<R> callbackFunction

    The callback function.

    Returns
    Type Description
    Future<R>
    Type Parameters
    Name Description
    R

    Implements

    IPromise

    Extension Methods

    FutureExtensions.AsTask<T>(Future<T>)
    FutureExtensions.AsTaskAsync<T>(Future<T>)
    FutureExtensions.AsTask<T>(Future<T>, TaskCreationOptions)
    FutureExtensions.GetAwaiter<T>(Future<T>)
    In This Article
    Back to top Copyright © LiveSwitch Inc. All Rights Reserved. Doc build for LiveSwitch v1.15.0