Delegate Invocation

A delegate is invoked using an invocation expression. When a non-empty delegate instance, which invocation list contains one element, is invoked, it invokes the corresponding method with the same argument values passed on the dialog call, and returns the same value returned by this method. If an exception occurs during the invocation of such a delegate, and that exception is not handled within the method that was invoked, the search for an exception handler continues in the method that called the delegate, as if that method had directly called the delegate method.

Invocation of a delegate instance, which invocation list contains multiple elements, proceeds by invoking each of the methods in the invocation list, synchronously, in order. Each method is called with the same set of arguments as was given to the delegate instance. If such a delegate has output parameters (Out) or a returned value, their final value will come from the invocation of the last method in the list.

If an exception occurs the during invocation, and that exception is not handled within the method that was invoked, the search for an exception handler continues in the body of the method that called the delegate. Any methods further down the invocation list are not invoked.

Attempting to invoke a delegate instance, which value is empty (Null) results in an exception of the System.NullReferenceException type.

Example

The example of delegate invocation is given in the Creating a Delegate section.

See also:

Delegates