WorkflowRuntime.RemoveService(Object) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从工作流运行时引擎中移除指定的服务。
public:
void RemoveService(System::Object ^ service);
public void RemoveService (object service);
member this.RemoveService : obj -> unit
Public Sub RemoveService (service As Object)
参数
- service
- Object
一个对象,表示要移除的服务。
例外
service
为空引用(在 Visual Basic 中为 Nothing
)。
示例
在下面的示例中,将向 SqlWorkflowPersistenceService 添加和移除一个 WorkflowRuntime。
// Create a new workflow runtime
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
// Create a new instance of the out-of-box SqlWorkflowPersistenceService
SqlWorkflowPersistenceService persistenceService =
new SqlWorkflowPersistenceService(
"Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;");
// Add the service to the runtime
workflowRuntime.AddService(persistenceService);
// Start the runtime
workflowRuntime.StartRuntime();
// Stop the runtime
workflowRuntime.StopRuntime();
// Remove the service from the runtime
workflowRuntime.RemoveService(persistenceService);
' Create a new workflow runtime
Dim workflowRuntime As New WorkflowRuntime()
' Create a new instance of the out-of-box SqlWorkflowPersistenceService
Dim persistenceService As New SqlWorkflowPersistenceService( _
"Initial Catalog=SqlPersistenceServiceData Source=localhostIntegrated Security=SSPI")
' Add the service to the runtime
workflowRuntime.AddService(persistenceService)
' Start the runtime
workflowRuntime.StartRuntime()
' Stop the runtime
workflowRuntime.StopRuntime()
' Remove the service from the runtime
workflowRuntime.RemoveService(persistenceService)
注解
当工作流运行时引擎正在运行 (IsStartedtrue
) 时,无法删除核心服务。 核心服务是派生自 WorkflowSchedulerService 类、WorkflowCommitWorkBatchService 类、WorkflowPersistenceService 类或 TrackingService 类的服务。 如果 service
派生自 WorkflowRuntimeService 类,则 RemoveService 将调用由 Stop 实现的 service
方法。