本文整理汇总了C#中System.Activities.WorkflowApplicationUnhandledExceptionEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# WorkflowApplicationUnhandledExceptionEventArgs类的具体用法?C# WorkflowApplicationUnhandledExceptionEventArgs怎么用?C# WorkflowApplicationUnhandledExceptionEventArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WorkflowApplicationUnhandledExceptionEventArgs类属于System.Activities命名空间,在下文中一共展示了WorkflowApplicationUnhandledExceptionEventArgs类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplicationException
Activity wf = new Sequence
{
Activities =
{
new WriteLine
{
Text = "Starting the workflow."
},
new Throw
{
Exception = new InArgument<Exception>((env) =>
new ApplicationException("Something unexpected happened."))
},
new WriteLine
{
Text = "Ending the workflow."
}
}
};
WorkflowApplication wfApp = new WorkflowApplication(wf);
wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
// Display the unhandled exception.
Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
e.InstanceId, e.UnhandledException.Message);
Console.WriteLine("ExceptionSource: {0} - {1}",
e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);
// Instruct the runtime to terminate the workflow.
return UnhandledExceptionAction.Terminate;
// Other choices are UnhandledExceptionAction.Abort and
// UnhandledExceptionAction.Cancel
};
wfApp.Run();