Jobs and Results
ExecutionJob, JobState, run results and engine-level execution records
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.
Table of Contents
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.
| Member | Description |
|---|---|
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. |
JobStateChanged | Event 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
| Member | Type | Description |
|---|---|---|
Id | string | Short unique job id (8 characters). |
WorkflowId / WorkflowName | string | What was submitted. |
SubmittedBy | string | Caller identity recorded with the job. |
SubmittedAt / StartedAt / CompletedAt | DateTime / DateTime? | Lifecycle timestamps (UTC). |
State | JobState | Current queue/execution state. |
Inputs | Dictionary<string, object> | Input values passed at submit time (case-insensitive keys). |
ExecutionId | string | Id of the underlying engine execution. |
Result | WorkflowResult | Populated when the job completes. |
Error | string | Failure message when the job fails. |
Duration | TimeSpan? | Derived from start and completion timestamps. |
Job States
| State | Meaning |
|---|---|
Queued | Submitted and waiting for a concurrency slot. |
Running | Executing nodes. |
Paused | Suspended at a safe point; Resume continues it. |
Completed | Finished successfully; Result is available. |
Failed | Stopped by an error; Error carries the message. |
Cancelled | Cancelled 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:
| Type | Key members | Purpose |
|---|---|---|
WorkflowExecution | ExecutionId, WorkflowId, Context, Status, CreatedTime, StartTime, EndTime, ExecutionTime | One record per workflow run, with the shared ExecutionContext (variables and inputs). |
NodeExecution | NodeId, ExecutionId, Status, CreatedTime, StartTime | One record per node, with a NodeStatus of Idle, Initializing, Executing, Completed, Failed, Cancelled or Disabled. |
WorkflowExecutionEventArgs | Execution record | Raised by the engine for workflow-level lifecycle changes. |
NodeExecutionEventArgs | Node execution record | Raised 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.