本文整理匯總了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();