UnhandledExceptionAction 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
예외가 워크플로의 루트를 이스케이프할 때 발생하는 작업을 지정합니다.
public enum class UnhandledExceptionAction
public enum UnhandledExceptionAction
type UnhandledExceptionAction =
Public Enum UnhandledExceptionAction
- 상속
필드
| Name | 값 | Description |
|---|---|---|
| Abort | 0 | 워크플로를 WorkflowApplication 중단해야 임을 지정합니다. 그러면 중단 프로세스가 완료된 bwhen에서 Aborted 반환된 대리자를 호출하게 됩니다. 처리되지 않은 예외는 중단 이유로 사용됩니다. |
| Cancel | 1 | 루트 작업의 취소를 예약하고 실행을 다시 시작해야 되도록 지정 WorkflowApplication 합니다. 그러면 취소 프로세스가 완료되면 속성에서 반환된 Completed 대리자를 호출합니다. |
| Terminate | 2 | 루트 작업의 종료를 WorkflowApplication 예약하고 실행을 다시 시작해야 되도록 지정합니다. 이렇게 하면 종료 프로세스가 완료되면 속성에 Completed할당된 대리자를 호출합니다. 처리되지 않은 예외는 종료 이유로 사용됩니다.
|
예제
다음 예제에서는 예외를 throw하는 워크플로를 호출합니다. 예외는 워크플로에서 처리되지 않으며 OnUnhandledException 처리기가 호출됩니다. WorkflowApplicationUnhandledExceptionEventArgs 검사하여 예외에 대한 정보를 제공하고 워크플로가 종료됩니다.
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;
};
wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
// Display the exception that caused the workflow
// to abort.
Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.Reason.GetType().FullName,
e.Reason.Message);
};
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
if (e.CompletionState == ActivityInstanceState.Faulted)
{
Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.TerminationException.GetType().FullName,
e.TerminationException.Message);
}
else if (e.CompletionState == ActivityInstanceState.Canceled)
{
Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
}
else
{
Console.WriteLine("Workflow {0} Completed.", e.InstanceId);
// Retrieve the outputs of the workflow.
foreach (var kvp in e.Outputs)
{
Console.WriteLine("Name: {0} - Value {1}",
kvp.Key, kvp.Value);
}
// Outputs can be directly accessed by argument name.
// Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
}
};
wfApp.Run();
다음 예제에서는 예외를 throw하는 워크플로를 호출합니다. 예외는 워크플로에서 처리되지 않으며 OnUnhandledException 처리기가 호출됩니다. WorkflowApplicationUnhandledExceptionEventArgs 예외에 대한 정보를 제공하기 위해 검사되고 워크플로가 중단됩니다.
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 abort the workflow.
return UnhandledExceptionAction.Abort;
};
wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
// Display the exception that caused the workflow
// to abort.
Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.Reason.GetType().FullName,
e.Reason.Message);
};
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
if (e.CompletionState == ActivityInstanceState.Faulted)
{
Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.TerminationException.GetType().FullName,
e.TerminationException.Message);
}
else if (e.CompletionState == ActivityInstanceState.Canceled)
{
Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
}
else
{
Console.WriteLine("Workflow {0} Completed.", e.InstanceId);
// Outputs can be retrieved from the Outputs dictionary,
// keyed by argument name.
// Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
}
};
wfApp.Run();
다음 예제에서는 예외를 throw하는 워크플로를 호출합니다. 예외는 워크플로에서 처리되지 않으며 OnUnhandledException 처리기가 호출됩니다. WorkflowApplicationUnhandledExceptionEventArgs 예외에 대한 정보를 제공하기 위해 검사되고 워크플로가 취소됩니다.
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 cancel the workflow.
return UnhandledExceptionAction.Cancel;
};
wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
// Display the exception that caused the workflow
// to abort.
Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.Reason.GetType().FullName,
e.Reason.Message);
};
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
if (e.CompletionState == ActivityInstanceState.Faulted)
{
Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
Console.WriteLine("Exception: {0}\n{1}",
e.TerminationException.GetType().FullName,
e.TerminationException.Message);
}
else if (e.CompletionState == ActivityInstanceState.Canceled)
{
Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
}
else
{
Console.WriteLine("Workflow {0} Completed.", e.InstanceId);
// Outputs can be retrieved from the Outputs dictionary,
// keyed by argument name.
// Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
}
};
wfApp.Run();
설명
OnUnhandledException 예외가 워크플로의 루트를 이스케이프하는 경우 함수가 호출됩니다. 예외 WorkflowApplicationUnhandledExceptionEventArgs 에 대한 액세스뿐만 아니라 예외를 생성한 포인터 Activity 도 제공합니다. 처리기가 지정되지 않은 OnUnhandledException 경우 Terminate는 기본 작업입니다.