Workflow Services
WF includes classes to provide some important services, such as making workflows executable, schedulable, transactional, and persistent. We'll explore some of these services in greater detail in Chapter 13; for now, this section will provide a quick overview.
As discussed earlier, in order for a workflow to be executable it needs a runtime. Runtime services are provided by the WorkflowRuntime class. You can initialize a runtime by calling new WorkflowRuntime(). Through WorkflowRuntime's AddService() method, you can make one or more services available to the runtime.
Once you have a new instance of the WorkflowRuntime and you have called StartRuntime(), you begin the process that allows you to execute your workflow activities. The call to CreateWorkflow() returns an instantiated WorkflowInstance. You call that object's Start() method to begin the execution of the activities in your workflow, which continues until either the workflow is complete or an exception occurs. In both cases termination of the workflow is the end result, as depicted in Figure 12-15.

Figure 12-15. Windows Workflow in action
When it comes to scheduling services, you have two out-of-the-box options: the DefaultWorkflowSchedulerService class asynchronously creates the new threads necessary to execute workflows without blocking any application threads, and the ManualWorkflowSchedulerService class is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access