संपादित करें

इसके माध्यम से साझा किया गया


Catch<TException> Class

Definition

Contains the actions to be executed after an exception is raised in the corresponding Try block of a Finally activity.

generic <typename TException>
 where TException : Exceptionpublic ref class Catch sealed : System::Activities::Statements::Catch
[System.Windows.Markup.ContentProperty("Action")]
public sealed class Catch<TException> : System.Activities.Statements.Catch where TException : Exception
[<System.Windows.Markup.ContentProperty("Action")>]
type Catch<'Exception (requires 'Exception :> Exception)> = class
    inherit Catch
Public NotInheritable Class Catch(Of TException)
Inherits Catch

Type Parameters

TException

The type of exception that the Catch<TException> block is handling.

Inheritance
Catch<TException>
Attributes

Examples

The following code sample demonstrates creating a Catch<TException> activity. This example is from the Fault Handling in a Flowchart Activity Using TryCatch sample.

FlowStep mwkStep = new FlowStep
{
    Action = new TryCatch
    {
        DisplayName = "Try/Catch for Divide By Zero Exception",
        Try = new Assign
        {
            DisplayName = "discount = 15 + (1 - 1/numberOfKids)*10",
            To = new OutArgument<double>(discount),
            Value = new InArgument<double>((ctx) => (15 + (1 - 1 / numberOfKids.Get(ctx)) * 10))
        },
        Catches =
        {
             new Catch<System.DivideByZeroException>
             {
                 Action = new ActivityAction<System.DivideByZeroException>
                 {
                     Argument = ex,
                     DisplayName = "ActivityAction - DivideByZeroException",
                     Handler =
                         new Sequence
                         {
                             DisplayName = "Divide by Zero Exception Workflow",
                             Activities =
                             {
                                new WriteLine()
                                {
                                    DisplayName = "WriteLine: DivideByZeroException",
                                    Text = "DivideByZeroException: Promo code is MWK - but number of kids = 0"
                                },
                                new Assign<double>
                                {
                                    DisplayName = "Exception - discount = 0",
                                    To = discount,
                                    Value = new InArgument<double>(0)
                                }
                             }
                         }
                 }
             }
        }
    },
    Next = flowDecision
};

Remarks

Once placed in the designer, Catch activities cannot be reordered in the designer. To reorder the collection of Catch activities, either delete and re-add them in the correct order, or use the xaml (code) view for the workflow.

Constructors

Catch<TException>()

Creates a new instance of the Catch<TException> class.

Properties

Action

The handler for the exception being caught.

ExceptionType

The type of exception that the Catch block is handling.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to