Skip to content

04. Workflow and Async Runtime

This module explains the hardest part of the workstation: not a single async method, but the coordination of state, workflow, background services, cancellation, streaming, and UI projection.

Instead of keeping everything in one long page, this topic is now split into smaller learning units:

  1. Why Runtime Coordination Is Hard
  2. Central App State and Workflow Ownership
  3. Stop, Abort, Fault, and Cancellation
  4. Streaming, Backpressure, and UI Responsiveness
  5. Code Tour, Mistakes, and Exercises

Why This Module Matters

This repo is a good teaching system because it contains the kinds of runtime problems that appear in real industrial desktop software:

  • multiple background producers
  • explicit machine and workflow states
  • different termination modes
  • bounded pipelines
  • UI thread affinity
  • durable terminal outcomes

The key idea behind the whole module is simple:

  • the runtime stays understandable because the repo separates state ownership, orchestration, background consumption, and UI projection

Quick Runtime Ownership Sketch

text
Operator
   |
   v
MainWindow -> MainViewModel -> WorkflowService
                  |                |
                  |                +--> Motion / Camera / Fault paths
                  |                |
                  v                v
             CommandGuards     AppStateStore <- TelemetryPipelineService
                  |                ^           <- FramePipelineService
                  +--------------> AppState
                                   |
                                   v
                                WPF UI

This is the core runtime story of the repo: commands and background work meet in the application layer, then become one canonical state that the UI projects.

Best Reading Order

If you are new to the repo, read the pages in order.

If you already understand the overall architecture, jump directly to:

  • page 02 for state and ownership
  • page 03 for operational semantics
  • page 04 for streaming and responsiveness

Pair This With

After this module, the best next page is:

Diagram Brief

  • Title: Workflow and async runtime overview
  • Purpose: Provide one top-level map of state ownership, orchestration, pipelines, and UI projection before the learner goes into the detailed pages
  • Audience: newcomer developer or automation engineer
  • Nodes: MainWindow, MainViewModel, CommandGuards, AppStateStore, AppState, WorkflowService, TelemetryPipelineService, FramePipelineService, FaultInjector, MotionController, CameraController
  • Edges: UI commands flow into workflow orchestration; orchestration and pipelines update canonical state; guards read canonical state; the view model projects state to the UI thread
  • Grouping: UI layer, application runtime core, background producers, infrastructure seams
  • Caption: The runtime stays teachable because responsibility is separated even though the system is highly stateful
  • Destination file path: docs/diagrams/source/course-04-runtime-overview.drawio

Docs-first project memory for AI-assisted implementation.