Class AsyncOperation
Factory for creating inline async operations (terminating step functions). Use this for simple cases where you don't need to create a separate class.
public static class AsyncOperation
- Inheritance
-
AsyncOperation
- Inherited Members
Methods
Create<TState>(Func<TState, bool>, Action<TState>, string)
Creates an async operation with a single outcome.
Example:
.Triggers(AsyncOperation.Create<PetImagesState>(
isTerminal: s => s.Images[name].State != "Creating",
transition: nextState => {
nextState.Images[name].State = "Created";
}
))
public static TerminatingStepFunction Create<TState>(Func<TState, bool> isTerminal, Action<TState> transition, string name = null) where TState : class, IState
Parameters
isTerminalFunc<TState, bool>Predicate that returns true when the background work is complete.
transitionAction<TState>Action that mutates a cloned state to the next state. Only called when isTerminal is false.
namestringOptional name for logging/debugging.
Returns
Type Parameters
TStateThe state type.
Create<TState>(Func<TState, bool>, Action<TState>[], string)
Creates an async operation with multiple non-deterministic outcomes.
Example:
.Triggers(AsyncOperation.Create<PetImagesState>(
isTerminal: s => s.Images[name].State != "Creating",
transitions: new Action<PetImagesState>[] {
nextState => { nextState.Images[name].State = "Created"; },
nextState => { nextState.Images[name].State = "Failed"; }
}
))
public static TerminatingStepFunction Create<TState>(Func<TState, bool> isTerminal, Action<TState>[] transitions, string name = null) where TState : class, IState
Parameters
isTerminalFunc<TState, bool>Predicate that returns true when the background work is complete.
transitionsAction<TState>[]Array of actions, each defining one possible outcome. Each receives its own cloned state.
namestringOptional name for logging/debugging.
Returns
Type Parameters
TStateThe state type.