WorkflowRuntime 類別

定義

警告

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

代表工作流程的工作流程執行階段引擎提供的可設定執行環境。

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

範例

下列程式碼範例示範如何從工作流程主機使用 WorkflowRuntime 功能。 它提供如何使用 WorkflowRuntime 建構函式 (Constructor)、AddServiceStartRuntimeStopRuntime 方法的範例。 程式碼也會顯示在工作流程主機中使用 WorkflowInstance 方法建立 CreateWorkflow 物件的建議方法。 同時也會顯示如何設定 WorkflowCompletedWorkflowIdledWorkflowTerminated 事件的事件處理常式。

此程式碼範例是 取消工作流程 範例的一部分。

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

備註

注意

此資料討論已被汰換的類型及命名空間。 如需詳細資訊,請參閱 Windows Workflow Foundation 4.5 中即將淘汰的類型

WorkflowRuntime 會公開主應用程式和服務需要的功能以設定和控制工作流程執行階段引擎,以及收到變更工作流程執行階段引擎與其任何工作流程執行個體的通知。

建構函式

WorkflowRuntime()
已淘汰.

初始化 WorkflowRuntime 類別的新執行個體。

WorkflowRuntime(String)
已淘汰.

使用指定的應用程式組態檔區段,初始化 WorkflowRuntime 類別的新執行個體。

WorkflowRuntime(WorkflowRuntimeSection)
已淘汰.

使用指定的 WorkflowRuntime 中的設定,初始化 WorkflowRuntimeSection 類別的新執行個體。

屬性

IsStarted
已淘汰.

取得指出工作流程執行階段引擎是否已啟動的值。

Name
已淘汰.

取得或設定與 WorkflowRuntime 關聯的名稱。

方法

AddService(Object)
已淘汰.

加入指定的服務至工作流程執行階段引擎。

CreateWorkflow(Type)
已淘汰.

使用指定的工作流程 Type 建立新的工作流程執行個體。

CreateWorkflow(Type, Dictionary<String,Object>)
已淘汰.

使用指定的工作流程 Type 和指定之 Dictionary<TKey,TValue> 中的工作流程之引數來建立工作流程執行個體。

CreateWorkflow(Type, Dictionary<String,Object>, Guid)
已淘汰.

使用指定的參數建立工作流程執行個體。

CreateWorkflow(XmlReader)
已淘汰.

使用指定的 XmlReader 建立工作流程執行個體。

CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>)
已淘汰.

使用指定的 XmlReader 物件和包含在指定之 Dictionary<TKey,TValue> 中的引數建立工作流程執行個體。

CreateWorkflow(XmlReader, XmlReader, Dictionary<String,Object>, Guid)
已淘汰.

使用指定的參數建立工作流程執行個體。

Dispose()
已淘汰.

釋放 WorkflowRuntime 使用的資源。

Equals(Object)
已淘汰.

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetAllServices(Type)
已淘汰.

擷取已加入工作流程執行階段引擎的所有服務,這些服務實作或衍生自指定的 Type

GetAllServices<T>()
已淘汰.

擷取已加入工作流程執行階段引擎的所有服務,這些服務實作或衍生自指定的泛型型別。

GetHashCode()
已淘汰.

做為預設雜湊函式。

(繼承來源 Object)
GetLoadedWorkflows()
已淘汰.

取得集合,其中包含目前載入記憶體內的所有工作流程執行個體。

GetService(Type)
已淘汰.

從工作流程執行階段引擎中擷取屬於指定 Type 的服務。

GetService<T>()
已淘汰.

從工作流程執行階段引擎中擷取指定之泛型型別的服務。

GetType()
已淘汰.

取得目前執行個體的 Type

(繼承來源 Object)
GetWorkflow(Guid)
已淘汰.

擷取有指定之 Guid 的工作流程執行個體。

MemberwiseClone()
已淘汰.

建立目前 Object 的淺層複製。

(繼承來源 Object)
RemoveService(Object)
已淘汰.

從工作流程執行階段引擎中移除指定的服務。

StartRuntime()
已淘汰.

啟動工作流程執行階段引擎和工作流程執行階段引擎服務。

StopRuntime()
已淘汰.

停止工作流程執行階段引擎和執行階段服務。

ToString()
已淘汰.

傳回代表目前物件的字串。

(繼承來源 Object)

事件

ServicesExceptionNotHandled
已淘汰.

在衍生自 WorkflowRuntimeService 類別的服務呼叫 RaiseServicesExceptionNotHandledEvent(Exception, Guid) 時發生。

Started
已淘汰.

在工作流程執行階段引擎啟動時發生。

Stopped
已淘汰.

在工作流程執行階段引擎停止時發生。

WorkflowAborted
已淘汰.

在中止工作流程執行個體時發生。

WorkflowCompleted
已淘汰.

在完成工作流程執行個體時發生。

WorkflowCreated
已淘汰.

在建立工作流程執行個體時發生。

WorkflowIdled
已淘汰.

在工作流程執行個體進入閒置 (Idle) 狀態時發生。

WorkflowLoaded
已淘汰.

在工作流程執行個體載入記憶體中時發生。

WorkflowPersisted
已淘汰.

在工作流程執行個體的狀態被保存時發生。

WorkflowResumed
已淘汰.

在暫止後繼續執行工作流程執行個體時發生。

WorkflowStarted
已淘汰.

在啟動工作流程執行個體時發生。

WorkflowSuspended
已淘汰.

在暫止工作流程執行個體時發生。

WorkflowTerminated
已淘汰.

在結束工作流程執行個體時發生。

WorkflowUnloaded
已淘汰.

在工作流程執行個體從記憶體中卸載時發生。

適用於

執行緒安全性

此型別具備執行緒安全。