Editare

Partajați prin


WorkflowRuntimeService.Start Method

Definition

When overridden in a derived class, starts the service and changes the State to Starting.

protected public:
 virtual void Start();
protected internal virtual void Start ();
abstract member Start : unit -> unit
override this.Start : unit -> unit
Protected Friend Overridable Sub Start ()

Exceptions

Runtime is a null reference (Nothing in Visual Basic)

-or-

The service has already been started.

Examples

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.

protected override void Start()
{
    base.Start();
    //
    // This will throw if we are invalid to inform the host immediately
    ValidateEventLogSource(source);
}
Protected Overrides Sub Start()
    MyBase.Start()
    '
    ' This will throw if we are invalid to inform the host immediately
    ValidateEventLogSource(source)
End Sub

Remarks

Start is invoked by the workflow runtime engine on all of its services that derive from the WorkflowRuntimeService class when StartRuntime is called.

Start 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 Start 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 Start on your service. Therefore, in the Start 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 Start 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 Start event is raised.

Note

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 Start 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 Start method. You can test IsStarted to determine whether the workflow runtime engine has been started.

Start should only be called by the workflow runtime engine.

Applies to