Table of Contents

Class AsyncOperation

Namespace
Microsoft.Accordant
Assembly
Accordant.dll

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

isTerminal Func<TState, bool>

Predicate that returns true when the background work is complete.

transition Action<TState>

Action that mutates a cloned state to the next state. Only called when isTerminal is false.

name string

Optional name for logging/debugging.

Returns

TerminatingStepFunction

Type Parameters

TState

The 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

isTerminal Func<TState, bool>

Predicate that returns true when the background work is complete.

transitions Action<TState>[]

Array of actions, each defining one possible outcome. Each receives its own cloned state.

name string

Optional name for logging/debugging.

Returns

TerminatingStepFunction

Type Parameters

TState

The state type.