14.5. Exception throwing in delegates

When a delegate instance is invoked, and an unhandled exception occurs in one of the methods on the instance's invocation list, the remaining methods will not be invoked and the exception is thrown to the delegate instance's context (see Figure 14.4). The diagram shows the scenario whereby a delegate instance contains five methods in its invocation list. When this instance is invoked, Method1 and Method2 are invoked in turn. Let's assume that when Method3 is invoked, an unhandled exception occurs. As a result, Method4 and Method5 will not execute and the exception object is thrown to the delegate instance's context.

Figure 14.4. Method4 and Method5 will not execute if an exception occurs when Method3 is invoked.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.166.255