WorkflowApplicationUnhandledExceptionEventArgs Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Innehåller information om ett ohanterat undantag som inträffade i en arbetsflödesinstans.
public ref class WorkflowApplicationUnhandledExceptionEventArgs : System::Activities::WorkflowApplicationEventArgs
public class WorkflowApplicationUnhandledExceptionEventArgs : System.Activities.WorkflowApplicationEventArgs
type WorkflowApplicationUnhandledExceptionEventArgs = class
inherit WorkflowApplicationEventArgs
Public Class WorkflowApplicationUnhandledExceptionEventArgs
Inherits WorkflowApplicationEventArgs
- Arv
Exempel
I följande exempel anropas ett arbetsflöde som utlöser ett undantag. Undantaget hanteras inte av arbetsflödet och OnUnhandledException-hanteraren anropas. WorkflowApplicationUnhandledExceptionEventArgs inspekteras för att ange information om undantaget och arbetsflödet avslutas.
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();
Kommentarer
Om ett undantag utlöses av en aktivitet och inte hanteras är standardbeteendet att avsluta arbetsflödesinstansen. Om det finns en OnUnhandledException hanterare kan den åsidosätta det här standardbeteendet. Den här hanteraren ger upphovsmannen till arbetsflödet en möjlighet att tillhandahålla lämplig hantering, till exempel anpassad loggning, avbryta arbetsflödet, avbryta arbetsflödet eller avsluta arbetsflödet.
Egenskaper
| Name | Description |
|---|---|
| ExceptionSource |
Hämtar den aktivitet som är källan till det ohanterade undantaget. |
| ExceptionSourceInstanceId |
Hämtar den unika identifieraren för aktivitetsinstansen som är källan till det ohanterade undantaget. |
| InstanceId |
Den unika identifieraren för arbetsflödesinstansen. (Ärvd från WorkflowApplicationEventArgs) |
| UnhandledException |
Hämtar den Exception som inte hanteras av arbetsflödesinstansen. |
Metoder
| Name | Description |
|---|---|
| Equals(Object) |
Avgör om det angivna objektet är lika med det aktuella objektet. (Ärvd från Object) |
| GetHashCode() |
Fungerar som standard-hash-funktion. (Ärvd från Object) |
| GetInstanceExtensions<T>() |
Hämtar samlingen med tillägg av den angivna typen. (Ärvd från WorkflowApplicationEventArgs) |
| GetType() |
Hämtar den aktuella instansen Type . (Ärvd från Object) |
| MemberwiseClone() |
Skapar en ytlig kopia av den aktuella Object. (Ärvd från Object) |
| ToString() |
Returnerar en sträng som representerar det aktuella objektet. (Ärvd från Object) |