Assembly: System.Workflow.Runtime (in System.Workflow.Runtime.dll)
is also invoked by the workflow runtime engine when a workflow runtime engine service is added to the workflow runtime engine by a call to AddService after the workflow runtime engine has already started. The default implementation of tracks whether the service has been started and uses this information to throw the appropriate exception if the service is started while it is already running.
You can provide additional functionality necessary to have your service started by the workflow runtime engine by overriding this method. There is no guarantee about which, if any, services will be running when the workflow runtime engine calls on your service. Therefore, in the method, you should only perform any initialization that does not depend on functionality provided by other services. This includes functionality provided by core services such as the scheduler service. The workflow runtime engine raises the WorkflowRuntime.Started event after it has called the method of all of its workflow runtime engine services. If your service requires additional initialization after all of the workflow runtime engine services have been started, you can override the OnStarted method in order to perform this initialization when the event is raised.
If your service is added to the workflow runtime engine by a call to AddService after the workflow runtime engine has already been started, the workflow runtime engine will call on your service. However, in this situation, the Started event has already occurred, therefore, your service may have to perform any initialization that it would ordinarily perform in OnStarted from inside the method. You can test IsStarted to determine whether the workflow runtime engine has been started.
should only be called by the workflow runtime engine.
The following example demonstrates calling the Start method on an object derived from WorkflowRuntimeService, TerminationTrackingService. This example is from the Termination Tracking Service SDK sample. For more information, see Termination Tracking Service Sample.