The Workflow Engine page covers the execution model. This page documents the types you interact with when running workflows programmatically: the job lifecycle, state transitions, results and the engine-level execution records behind them.

Execution Service

WorkflowExecutionService owns published workflows and the job queue. It is thread-safe and disposable; hosts usually keep one instance for the process lifetime.

MemberDescription
Publish(WorkflowDefinition)Registers a workflow definition for execution.
RemoveWorkflow(id) / GetWorkflow(id)Manage and look up published workflows.
Submit(workflowId, submittedBy, inputs)Queues a job and returns the ExecutionJob immediately.
GetJob(id) / GetJobs(state, limit)Read job state, optionally filtered by JobState.
Cancel(id) / Pause(id) / Resume(id)Control a running or paused job; each returns whether the transition was accepted.
WaitForCompletion(id, timeout)Blocks until the job reaches a terminal state or the timeout expires.
JobStateChangedEvent raised on every state transition, with old and new state.
using var service = new WorkflowExecutionService(maxConcurrency: 2);

service.JobStateChanged += (s, e) =>
    Console.WriteLine($"{e.Job.Id}: {e.OldState} -> {e.NewState}");

service.Publish(drawingManager.ToWorkflowDefinition("Nightly Sync"));

var job = service.Submit("Nightly Sync", submittedBy: "me",
    inputs: new Dictionary<string, object> { ["threshold"] = 10 });

if (service.WaitForCompletion(job.Id, TimeSpan.FromSeconds(30)))
    Console.WriteLine($"Result: {job.Result?.Status} in {job.Duration}");
else
    service.Cancel(job.Id);

ExecutionJob

MemberTypeDescription
IdstringShort unique job id (8 characters).
WorkflowId / WorkflowNamestringWhat was submitted.
SubmittedBystringCaller identity recorded with the job.
SubmittedAt / StartedAt / CompletedAtDateTime / DateTime?Lifecycle timestamps (UTC).
StateJobStateCurrent queue/execution state.
InputsDictionary<string, object>Input values passed at submit time (case-insensitive keys).
ExecutionIdstringId of the underlying engine execution.
ResultWorkflowResultPopulated when the job completes.
ErrorstringFailure message when the job fails.
DurationTimeSpan?Derived from start and completion timestamps.

Job States

StateMeaning
QueuedSubmitted and waiting for a concurrency slot.
RunningExecuting nodes.
PausedSuspended at a safe point; Resume continues it.
CompletedFinished successfully; Result is available.
FailedStopped by an error; Error carries the message.
CancelledCancelled by request.

JobStateChangedEventArgs carries the Job, OldState and NewState, which is everything a UI needs to update a queue view without polling.

Results

WorkflowResult summarizes an engine execution: WorkflowId, ExecutionId, Status (WorkflowStatus), StartTime and the per-node outcomes. Combine it with ExecutionJob.Duration for timing and with the pipeline metrics for throughput.

var job = service.Submit(workflowId);

if (service.WaitForCompletion(job.Id, TimeSpan.FromSeconds(30)))
{
    var result = job.Result;
    Console.WriteLine($"{result?.Status} in {job.Duration}");

    foreach (var node in result?.NodeResults ?? Array.Empty<NodeResult>())
    {
        Console.WriteLine($"{node.Success} in {node.ExecutionTime}" +
                          (node.Success ? "" : $" - {node.ErrorMessage}"));
    }
}

NodeResult carries Success/IsSuccess, OutputData, ErrorMessage, ExecutionTime, Timestamp and a Metadata bag. WorkflowResult also exposes the merged OutputData, an Errors list and its own Metadata.

Engine Execution Records

Beneath the service, the engine tracks one WorkflowExecution per run and one NodeExecution per node:

TypeKey membersPurpose
WorkflowExecutionExecutionId, WorkflowId, Context, Status, CreatedTime, StartTime, EndTime, ExecutionTimeOne record per workflow run, with the shared ExecutionContext (variables and inputs).
NodeExecutionNodeId, ExecutionId, Status, CreatedTime, StartTimeOne record per node, with a NodeStatus of Idle, Initializing, Executing, Completed, Failed, Cancelled or Disabled.
WorkflowExecutionEventArgsExecution recordRaised by the engine for workflow-level lifecycle changes.
NodeExecutionEventArgsNode execution recordRaised per node as it starts and finishes.

The HTTP layer maps these records to JSON responses through WorkflowHttpRequest and WorkflowHttpResponse; see the Server Execution SKU page for the route table.