csharp System.Activities.WorkflowApplicationUnhandledExceptionEventArgs类(方法)实例源码

下面列出了csharp System.Activities.WorkflowApplicationUnhandledExceptionEventArgs 类(方法)源码代码实例,从而了解它的用法。

作者:.NET开发    项目:System.Activitie   
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();


问题


面经


文章

微信
公众号

扫码关注公众号