Occurrs when a Workflow instance is terminated

Namespace:  EPiServer.WorkflowFoundation.Interfaces
Assembly:  EPiServer.WorkflowFoundation (in EPiServer.WorkflowFoundation.dll) Version: 6.0.530.0

Syntax

C#
event EventHandler<WorkflowTerminatedEventArgs> WorkflowTerminated

Remarks

It is possible to get the corresponding WorkflowDefinitionInstance in this event. It will though not be possible to edit it since it will be deleted

Examples

Example on how terminated event can be used to clean up
CopyC#
//Checks if a terminated workflow is of a our type and if so logs it in own log
ILog log = LogManager.GetLogger(typeof(EventListener));
WorkflowSystem.WorkflowManager.WorkflowTerminated +=
    delegate(object sender, System.Workflow.Runtime.WorkflowTerminatedEventArgs e)
    {
        WorkflowDefinitionInstance instance = WorkflowSystem.InstanceHandler.GetInstance(e.WorkflowInstance.InstanceId, EPiServer.Security.AccessLevel.NoAccess);
        if (instance.Type == typeof(CodeSamples.WorkflowFoundation.Attributes.CustomWorkflow))
        {
            log.Error("An workflow instance terminated", e.Exception);
        }
    };

See Also