When a WF program instance completes normally (the root activity moves to the Closed state of the activity automaton, and there is no unhandled exception), the WorkflowCompleted event is raised by WorkflowRuntime. In the handler of this event, the host is able to inspect the values of all gettable public properties of the root activity of the instance. This is shown in the following snippet, which uses the OutputParameters property of WorkflowCompletedEventArgs: using (WorkflowRuntime runtime = new WorkflowRuntime()) { runtime.StartRuntime(); runtime.WorkflowCompleted += delegate( object sender, WorkflowCompletedEventArgs e) { Dictionary<string, object> results = e.OutputParameters; foreach (string key in results.Keys) { object o = results[key]; ... } }; ... } As part of its completion, a WF program instance is unloaded if a persistence service is present. |