WorkflowRuntime 類別

定義

警告

此 API 現已淘汰。

代表工作流程的工作流程執行階段引擎提供的可設定執行環境。Represents the configurable execution environment provided by the workflow run-time engine for workflows.

public ref class WorkflowRuntime : IDisposable, IServiceProvider
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class WorkflowRuntime : IDisposable, IServiceProvider
type WorkflowRuntime = class
    interface IServiceProvider
    interface IDisposable
Public Class WorkflowRuntime
Implements IDisposable, IServiceProvider
繼承
WorkflowRuntime
屬性
實作

範例

下列程式碼範例示範如何從工作流程主機使用 WorkflowRuntime 功能。The following code example demonstrates how to use WorkflowRuntime functionality from a workflow host. 它提供如何使用 WorkflowRuntime 建構函式 (Constructor)、AddServiceStartRuntimeStopRuntime 方法的範例。It provides examples of how to use the WorkflowRuntime constructor and the AddService, StartRuntime, and StopRuntime methods. 程式碼也會顯示在工作流程主機中使用 WorkflowInstance 方法建立 CreateWorkflow 物件的建議方法。The code also shows the recommended way to create a WorkflowInstance object in a workflow host using the CreateWorkflow method. 同時也會顯示如何設定 WorkflowCompletedWorkflowIdledWorkflowTerminated 事件的事件處理常式。It also shows how to set event handlers for the WorkflowCompleted, WorkflowIdled, and WorkflowTerminated events.

這個程式碼範例是取消工作流程範例的一部分。This code example is part of the Canceling a Workflow sample.

static void Main()
{
    string connectionString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;";

    using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
    {
        ExternalDataExchangeService dataService = new ExternalDataExchangeService();
        workflowRuntime.AddService(dataService);
        dataService.AddService(expenseService);

        workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString));
        workflowRuntime.StartRuntime();

        workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
        workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
        workflowRuntime.WorkflowIdled += OnWorkflowIdled;
        workflowRuntime.WorkflowAborted += OnWorkflowAborted;

        Type type = typeof(SampleWorkflow1);
        WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
        workflowInstance.Start();

        waitHandle.WaitOne();

        workflowRuntime.StopRuntime();
    }
}
Shared Sub Main()
    Dim connectionString As String = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"
    Using workflowRuntime As New WorkflowRuntime()
        Dim dataService As New ExternalDataExchangeService()
        workflowRuntime.AddService(dataService)
        dataService.AddService(expenseService)

        workflowRuntime.AddService(New SqlWorkflowPersistenceService(connectionString))


        AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted
        AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated
        AddHandler workflowRuntime.WorkflowIdled, AddressOf OnWorkflowIdled
        AddHandler workflowRuntime.WorkflowAborted, AddressOf OnWorkflowAborted


        Dim workflowInstance As WorkflowInstance
        workflowInstance = workflowRuntime.CreateWorkflow(GetType(SampleWorkflow))
        workflowInstance.Start()

        waitHandle.WaitOne()

        workflowRuntime.StopRuntime()
    End Using
End Sub

備註

注意

此資料討論已被汰換的類型及命名空間。This material discusses types and namespaces that are obsolete. 如需詳細資訊,請參閱 Windows Workflow Foundation 4.5 中即將淘汰的類型For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

WorkflowRuntime 會公開主應用程式和服務需要的功能以設定和控制工作流程執行階段引擎,以及收到變更工作流程執行階段引擎與其任何工作流程執行個體的通知。WorkflowRuntime exposes functionality required by a host application and services to configure and control the workflow run-time engine and to be notified of changes to both the workflow run-time engine and any of its workflow instances.

建構函式

WorkflowRuntime()

初始化 WorkflowRuntime 類別的新執行個體。Initializes a new instance of the WorkflowRuntime class.

WorkflowRuntime(String)

使用指定的應用程式組態檔區段,初始化 WorkflowRuntime 類別的新執行個體。Initializes a new instance of the WorkflowRuntime class by using the specified section of the application configuration file.

WorkflowRuntime(WorkflowRuntimeSection)

使用指定的 WorkflowRuntime 中的設定,初始化 WorkflowRuntimeSection 類別的新執行個體。Initializes a new instance of the WorkflowRuntime class by using the settings in the specified WorkflowRuntimeSection.

屬性

IsStarted

取得指出工作流程執行階段引擎是否已啟動的值。Gets a value that indicates whether the workflow run-time engine has been started.

Name

取得或設定與 WorkflowRuntime 關聯的名稱。Gets or sets the name associated with the WorkflowRuntime.

方法

AddService(Object)

加入指定的服務至工作流程執行階段引擎。Adds the specified service to the workflow run-time engine.

CreateWorkflow(Type)

使用指定的工作流程 Type 建立新的工作流程執行個體。Creates a new workflow instance by using the specified workflow Type.

CreateWorkflow(Type, Dictionary<String,Object>)

使用指定的工作流程 Type 和指定之 Dictionary<TKey,TValue> 中的工作流程之引數來建立工作流程執行個體。Creates a workflow instance by using the specified workflow Type and the arguments to the workflow contained in the specified Dictionary<TKey,TValue>.

CreateWorkflow(Type, Dictionary<String,Object>, Guid)

使用指定的參數建立工作流程執行個體。Creates a workflow instance by using the specified parameters.

CreateWorkflow(XmlReader)

使用指定的 XmlReader 建立工作流程執行個體。Creates a workflow instance by using the specified XmlReader.

CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>)

使用指定的 XmlReader 物件和包含在指定之 Dictionary<TKey,TValue> 中的引數建立工作流程執行個體。Creates a workflow instance by using the specified XmlReader objects and the arguments contained in the specified Dictionary<TKey,TValue>.

CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>, Guid)

使用指定的參數建立工作流程執行個體。Creates a workflow instance by using the specified parameters.

Dispose()

釋放 WorkflowRuntime 使用的資源。Releases the resources used by the WorkflowRuntime.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetAllServices(Type)

擷取已加入工作流程執行階段引擎的所有服務,這些服務實作或衍生自指定的 TypeRetrieves all the services that are added to the workflow run-time engine that implement or derive from the specified Type.

GetAllServices<T>()

擷取已加入工作流程執行階段引擎的所有服務,這些服務實作或衍生自指定的泛型型別。Retrieves all the services that are added to the workflow run-time engine that implement or derive from the specified generic type.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetLoadedWorkflows()

取得集合,其中包含目前載入記憶體內的所有工作流程執行個體。Gets a collection that contains all the workflow instances currently loaded in memory.

GetService(Type)

從工作流程執行階段引擎中擷取屬於指定 Type 的服務。Retrieves a service of the specified Type from the workflow run-time engine.

GetService<T>()

從工作流程執行階段引擎中擷取指定之泛型型別的服務。Retrieves a service of the specified generic type from the workflow run-time engine.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GetWorkflow(Guid)

擷取有指定之 Guid 的工作流程執行個體。Retrieves the workflow instance that has the specified Guid.

MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
RemoveService(Object)

從工作流程執行階段引擎中移除指定的服務。Removes the specified service from the workflow run-time engine.

StartRuntime()

啟動工作流程執行階段引擎和工作流程執行階段引擎服務。Starts the workflow run-time engine and the workflow run-time engine services.

StopRuntime()

停止工作流程執行階段引擎和執行階段服務。Stops the workflow run-time engine and the run-time services.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

事件

ServicesExceptionNotHandled

在衍生自 WorkflowRuntimeService 類別的服務呼叫 RaiseServicesExceptionNotHandledEvent(Exception, Guid) 時發生。Occurs when a service that is derived from the WorkflowRuntimeService class calls RaiseServicesExceptionNotHandledEvent(Exception, Guid).

Started

在工作流程執行階段引擎啟動時發生。Occurs when the workflow run-time engine is started.

Stopped

在工作流程執行階段引擎停止時發生。Occurs when the workflow run-time engine is stopped.

WorkflowAborted

在中止工作流程執行個體時發生。Occurs when a workflow instance is aborted.

WorkflowCompleted

在完成工作流程執行個體時發生。Occurs when a workflow instance has completed.

WorkflowCreated

在建立工作流程執行個體時發生。Occurs when a workflow instance is created.

WorkflowIdled

在工作流程執行個體進入閒置 (Idle) 狀態時發生。Occurs when a workflow instance enters the idle state.

WorkflowLoaded

在工作流程執行個體載入記憶體中時發生。Occurs when the workflow instance is loaded into memory.

WorkflowPersisted

在工作流程執行個體的狀態被保存時發生。Occurs when the state of a workflow instance is persisted.

WorkflowResumed

在暫止後繼續執行工作流程執行個體時發生。Occurs when execution of a workflow instance is resumed following a suspension.

WorkflowStarted

在啟動工作流程執行個體時發生。Occurs when a workflow instance has been started.

WorkflowSuspended

在暫止工作流程執行個體時發生。Occurs when a workflow instance is suspended.

WorkflowTerminated

在結束工作流程執行個體時發生。Occurs when a workflow instance is terminated.

WorkflowUnloaded

在工作流程執行個體從記憶體中卸載時發生。Occurs when the workflow instance is unloaded from memory.

適用於

執行緒安全性

此型別具備執行緒安全。This type is thread safe.