Edit

Share via


WorkflowRuntime.Dispose Method

Definition

Releases the resources used by the WorkflowRuntime.

public:
 virtual void Dispose();
public void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()

Implements

Examples

The following example demonstrates how to call Dispose on a WorkflowRuntime object. In this sample, the Dispose method is called from the FormClosing event handler for the main form of the application; this ensures that the objects created by the runtime are properly cleaned up when the application shuts down. This sample is from the Speech Application Sample.

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    this.workflowRuntime.Dispose();
}
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
    Me.workflowRuntime.Dispose()
End Sub

Remarks

To shut down the WorkflowRuntime gracefully, you should only call Dispose after you have called StopRuntime. This is because calling the Dispose method alone leaves the WorkflowRuntime in an unusable state. Dispose frees the resources used by the runtime by closing open file handles, database connections, and so on, but it does not unload workflow instances, stop services, or do any of the other actions that StopRuntime does.

Dispose should be called only when the host application must free the resources used by the WorkflowRuntime before they are automatically freed by the garbage collector. For general information about Dispose, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.

Applies to