Creating Custom Scheduling Services
A workflow scheduler service is a service that is used by the workflow runtime engine to determine which threads are used to start workflows. By creating a custom workflow scheduler service, you can control what threads the workflow runtime uses.
Two workflow scheduler services are provided:
The DefaultWorkflowSchedulerService executes workflows on threads provided by the system thread pool.
The ManualWorkflowSchedulerService executes workflows on threads donated by the host application.
To create a custom scheduling service, you must derive from the WorkflowSchedulerService base class and provide implementations for three methods. These methods are called by the workflow runtime engine when it needs to execute workflows.
This method is called by the workflow runtime engine to request that a workflow instance be started immediately. The implementation of this method should invoke the callback method, on an appropriate thread, passing in the workflowInstanceId as a parameter.
This method is called by the workflow runtime engine to request that a workflow instance be executed sometime in the future. The implementation of this method should invoke the callback method, passing the workflowInstanceId. It should invoke the callback no earlier than the specified UTC time.
This method is called by the runtime engine to cancel a request for a previously scheduled workflow. The System.Guid that is passed as a parameter to this method will match the timerId parameter of a previous invocation of the Schedule method. Requests to cancel workflows that have already executed can be ignored.
Note: When a workflow is unloaded, its outstanding schedule requests are canceled. When a workflow is reloaded, the requests are rescheduled at that time.