Show / Hide Table of Contents

Class Promises

Various methods useful for interacting with promises

Inheritance
System.Object
Promises
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Innovator.Client
Assembly: Innovator.Client.dll
Syntax
public static class Promises

Methods

| Improve this Doc View Source

All(IPromise[])

Creates a promise that is resolved when all of the specified arguments are resolved

Declaration
public static IPromise<IList<object>> All(params IPromise[] promises)
Parameters
Type Name Description
IPromise[] promises
Returns
Type Description
IPromise<System.Collections.Generic.IList<System.Object>>
| Improve this Doc View Source

All<T1>(IPromise<T1>)

Creates a promise that is resolved when all of the specified arguments are resolved

Declaration
public static IPromise<T1> All<T1>(IPromise<T1> promise1)
Parameters
Type Name Description
IPromise<T1> promise1
Returns
Type Description
IPromise<T1>
Type Parameters
Name Description
T1
| Improve this Doc View Source

All<T1, T2>(IPromise<T1>, IPromise<T2>)

Creates a promise that is resolved when all of the specified arguments are resolved

Declaration
public static IPromise<PromiseResult<T1, T2>> All<T1, T2>(IPromise<T1> promise1, IPromise<T2> promise2)
Parameters
Type Name Description
IPromise<T1> promise1
IPromise<T2> promise2
Returns
Type Description
IPromise<PromiseResult<T1, T2>>
Type Parameters
Name Description
T1
T2
| Improve this Doc View Source

All<T1, T2, T3>(IPromise<T1>, IPromise<T2>, IPromise<T3>)

Creates a promise that is resolved when all of the specified arguments are resolved

Declaration
public static IPromise<PromiseResult<T1, T2, T3>> All<T1, T2, T3>(IPromise<T1> promise1, IPromise<T2> promise2, IPromise<T3> promise3)
Parameters
Type Name Description
IPromise<T1> promise1
IPromise<T2> promise2
IPromise<T3> promise3
Returns
Type Description
IPromise<PromiseResult<T1, T2, T3>>
Type Parameters
Name Description
T1
T2
T3
| Improve this Doc View Source

All<T1, T2, T3, T4>(IPromise<T1>, IPromise<T2>, IPromise<T3>, IPromise<T4>)

Creates a promise that is resolved when all of the specified arguments are resolved

Declaration
public static IPromise<PromiseResult<T1, T2, T3, T4>> All<T1, T2, T3, T4>(IPromise<T1> promise1, IPromise<T2> promise2, IPromise<T3> promise3, IPromise<T4> promise4)
Parameters
Type Name Description
IPromise<T1> promise1
IPromise<T2> promise2
IPromise<T3> promise3
IPromise<T4> promise4
Returns
Type Description
IPromise<PromiseResult<T1, T2, T3, T4>>
Type Parameters
Name Description
T1
T2
T3
T4
| Improve this Doc View Source

Cancelled<T>(IPromise<T>, Action<OperationCanceledException>)

Attach a callback that runs when the promise is canceled

Declaration
public static IPromise<T> Cancelled<T>(this IPromise<T> promise, Action<OperationCanceledException> callback)
Parameters
Type Name Description
IPromise<T> promise
System.Action<System.OperationCanceledException> callback
Returns
Type Description
IPromise<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

ConfigureAwait<T>(IPromise<T>, Boolean)

Configures an awaiter used to await this IPromise<T>

Declaration
public static ConfiguredTaskAwaitable<T> ConfigureAwait<T>(this IPromise<T> promise, bool continueOnCapturedContext)
Parameters
Type Name Description
IPromise<T> promise

The promise to configure the awaig for.

System.Boolean continueOnCapturedContext

true to attempt to marshal the continuation back to the original context captured; otherwise, false.

Returns
Type Description
System.Runtime.CompilerServices.ConfiguredTaskAwaitable<T>

An object used to await this promise.

Type Parameters
Name Description
T
| Improve this Doc View Source

Continue<T, S>(IPromise<T>, Func<T, IPromise<S>>)

Continue a promise chain by acting on the previous promise's result and returning a new promise

Declaration
public static IPromise<S> Continue<T, S>(this IPromise<T> promise, Func<T, IPromise<S>> callback)
Parameters
Type Name Description
IPromise<T> promise

Previous promise

System.Func<T, IPromise<S>> callback

Code to execute on resolution of the promise and returning a new promise

Returns
Type Description
IPromise<S>

A new promise

Type Parameters
Name Description
T
S
| Improve this Doc View Source

Convert<T, S>(IPromise<T>, Action<T, Promise<S>>, Action<Exception, Promise<S>>)

Convert a promise by modifying the done/fail logic in addition to transforming the type.

Declaration
public static IPromise<S> Convert<T, S>(this IPromise<T> promise, Action<T, Promise<S>> doneCallback, Action<Exception, Promise<S>> failCallback)
Parameters
Type Name Description
IPromise<T> promise
System.Action<T, Promise<S>> doneCallback
System.Action<System.Exception, Promise<S>> failCallback
Returns
Type Description
IPromise<S>
Type Parameters
Name Description
T
S
| Improve this Doc View Source

Convert<T, S>(IPromise<T>, Func<T, S>)

Convert a promise using a simple transformation to go from one type to another

Declaration
public static IPromise<S> Convert<T, S>(this IPromise<T> promise, Func<T, S> callback)
Parameters
Type Name Description
IPromise<T> promise
System.Func<T, S> callback
Returns
Type Description
IPromise<S>
Type Parameters
Name Description
T
S
| Improve this Doc View Source

Error<T>(IPromise<T>, Action<Exception>)

Attach a callback that runs an error (other than a cancellation error) occurs

Declaration
public static IPromise<T> Error<T>(this IPromise<T> promise, Action<Exception> callback)
Parameters
Type Name Description
IPromise<T> promise
System.Action<System.Exception> callback
Returns
Type Description
IPromise<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Error<TErr, T>(IPromise<T>, Action<TErr>)

Attach a callback that runs when an error (other than a cancellation error) occurs

Declaration
public static IPromise<T> Error<TErr, T>(this IPromise<T> promise, Action<TErr> callback)where TErr : Exception
Parameters
Type Name Description
IPromise<T> promise
System.Action<TErr> callback
Returns
Type Description
IPromise<T>
Type Parameters
Name Description
TErr
T
| Improve this Doc View Source

FailOver<T>(IPromise<T>, Func<IPromise<T>>)

Attach a callback that performs new asyncronous work when the original promise fails

Declaration
public static IPromise<T> FailOver<T>(this IPromise<T> promise, Func<IPromise<T>> callback)
Parameters
Type Name Description
IPromise<T> promise
System.Func<IPromise<T>> callback
Returns
Type Description
IPromise<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

GetAwaiter<T>(IPromise<T>)

Make it so that the user can directly await a promise

Declaration
public static TaskAwaiter<T> GetAwaiter<T>(this IPromise<T> promise)
Parameters
Type Name Description
IPromise<T> promise
Returns
Type Description
System.Runtime.CompilerServices.TaskAwaiter<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Pooled(Int32, Func<IPromise>[])

Return a promise that resolves upon completion of all the contained promises. Only allow a select number of promises to be active at a given time.

Declaration
public static IPromise<IList<object>> Pooled(int poolSize, params Func<IPromise>[] promises)
Parameters
Type Name Description
System.Int32 poolSize

Number of promises that can be active simultaneously

System.Func<IPromise>[] promises

Factory for creating the promises

Returns
Type Description
IPromise<System.Collections.Generic.IList<System.Object>>
| Improve this Doc View Source

Rejected<T>(Exception)

Create a new promise which is already rejected

Declaration
public static IPromise<T> Rejected<T>(Exception ex)
Parameters
Type Name Description
System.Exception ex
Returns
Type Description
IPromise<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Resolved<T>(T)

Create a new promise which is already resolved

Declaration
public static IPromise<T> Resolved<T>(T data)
Parameters
Type Name Description
T data
Returns
Type Description
IPromise<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

ToPromise<T>(Task<T>, CancellationTokenSource)

Convert a .Net 4.0 Task to a promise

Declaration
public static IPromise<T> ToPromise<T>(this Task<T> task, CancellationTokenSource cts = null)
Parameters
Type Name Description
System.Threading.Tasks.Task<T> task
System.Threading.CancellationTokenSource cts
Returns
Type Description
IPromise<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

ToTask<T>(IPromise<T>, CancellationToken)

Convert a promise to a .Net 4.0 Task for use with the async/await keywords

Declaration
public static Task<T> ToTask<T>(this IPromise<T> promise, CancellationToken ct = null)
Parameters
Type Name Description
IPromise<T> promise
System.Threading.CancellationToken ct
Returns
Type Description
System.Threading.Tasks.Task<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

Wait<T>(IPromise<T>)

Block the current thread waiting for a promise to complete

Declaration
public static T Wait<T>(this IPromise<T> promise)
Parameters
Type Name Description
IPromise<T> promise

The promise to wait for

Returns
Type Description
T

The resolved value of the promise

Type Parameters
Name Description
T
| Improve this Doc View Source

WithInvoker<T>(IPromise<T>, Action<Delegate, Object[]>)

Changes the invokation logic of the promise (e.g. to trigger invokation on the UI thread)

Declaration
public static IPromise<T> WithInvoker<T>(this IPromise<T> promise, Action<Delegate, object[]> invoker)
Parameters
Type Name Description
IPromise<T> promise
System.Action<System.Delegate, System.Object[]> invoker
Returns
Type Description
IPromise<T>

The original promise with the new invokation logic

Type Parameters
Name Description
T
  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX