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.

graphics/14fig04.gif



From Java to C#. A Developers Guide
From Java to C#: A Developers Guide
ISBN: 0321136225
EAN: 2147483647
Year: 2003
Pages: 221
Authors: Heng Ngee Mok

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net