Bagikan melalui


WorkflowRuntime.StopRuntime Metode

Definisi

Menghentikan mesin run-time alur kerja dan layanan run-time.

public:
 void StopRuntime();
public void StopRuntime ();
member this.StopRuntime : unit -> unit
Public Sub StopRuntime ()

Pengecualian

Contoh

Contoh kode berikut menunjukkan cara menggunakan WorkflowRuntime fungsionalitas dari host alur kerja. StopRuntime dipanggil setelah host menyelesaikan semua pemrosesan lain yang terkait dengan runtime.

Contoh kode ini adalah bagian dari sampel Membatalkan Alur Kerja .

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

Keterangan

Metode ini menyebabkan mesin run-time alur kerja untuk membongkar setiap instans alur kerjanya, menghentikan semua layanannya yang berasal dari WorkflowRuntimeService kelas, mengatur IsStarted ke false, dan menaikkan Stopped peristiwa.

Untuk mematikan dengan WorkflowRuntime anggun, hubungi StopRuntime sebelum Anda memanggil Dispose.

Untuk informasi lebih lanjut, lihat Disposemetodenya.

Berlaku untuk