Class Future<T>
A future.
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public abstract class Future<T> : FutureBase<T> where T : class
Type Parameters
| Name | Description |
|---|---|
| T | The type of the result. |
Methods
Fail(Action1<Exception>)
Appends a handler to be executed when the promise is rejected.
Declaration
public abstract Future<T> Fail(Action1<Exception> rejectAction)
Parameters
| Type | Name | Description |
|---|---|---|
| Action1<Exception> | rejectAction | The reject action. |
Returns
| Type | Description |
|---|---|
| Future<T> |
Fail(Function1<Exception, Future<T>>)
Appends a handler to be executed when the promise is rejected.
Declaration
public abstract 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> |
Then(Action1<T>)
Appends a handler to be executed when the promise is resolved.
Declaration
public abstract Future<T> Then(Action1<T> resolveAction)
Parameters
| Type | Name | Description |
|---|---|---|
| Action1<T> | resolveAction | The resolve action. |
Returns
| Type | Description |
|---|---|
| Future<T> |
Then(Action1<T>, Action1<Exception>)
Appends handlers to be executed when the promise is resolved or rejected.
Declaration
public abstract 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> |
Then<R>(Function1<T, Future<R>>)
Appends a handler to be executed when the promise is resolved.
Declaration
public abstract 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 |
Then<R>(Function1<T, Future<R>>, Action1<Exception>)
Appends handlers to be executed when the promise is resolved or rejected.
Declaration
public abstract 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 |
WaitForPromise()
Blocks the current thread from proceeding until the future state has been resolved or rejected.
Declaration
public void WaitForPromise()
WaitForPromise(Int32)
Blocks the current thread from proceeding until the future state has been resolved or rejected or if the timeout period elapses.
Declaration
public void WaitForPromise(int millisecondsTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | millisecondsTimeout | The number of milliseconds to wait before timing out. |
WaitForResult()
Blocks the current thread from proceeding until the future has a result. Throws an exception if the promise is rejected.
Declaration
public T WaitForResult()
Returns
| Type | Description |
|---|---|
| T |
WaitForResult(Int32)
Blocks the current thread from proceeding until the future has a result. Throws an exception if the promise is rejected or if the timeout period elapses.
Declaration
public T WaitForResult(int millisecondsTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | millisecondsTimeout | The number of milliseconds to wait before timing out. |
Returns
| Type | Description |
|---|---|
| T |