The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Miha Markic (3) [Avatar] Offline
#1
Hi Jon,

I am finally started reading your book smilie and have a suggestion about delegate chains/events:
Perhaps it is worth noting that an invocation of chain of (combined) delegates breaks if one implementation throws an unhandled exception, IOW if an event implementation throws an exception the subsequent handlers won't be called.
jon.skeet (483) [Avatar] Offline
#2
Re: 2.1.2 and 3 a suggestion
> I am finally started reading your book smilie

Glad to hear it smilie

> and have a
> suggestion about delegate chains/events:
> Perhaps it is worth noting that an invocation of
> chain of (combined) delegates breaks if one
> implementation throws an unhandled exception, IOW if
> an event implementation throws an exception the
> subsequent handlers won't be called.

Sounds reasonable to me. I've included this at the end of the paragraph directly after table 2.1:

If any of the actions throws an exception, that prevents any of the subsequent actions from being executed. For example, if a delegate instance with an action list [a, b, c] is invoked, and action b throws an exception, then the exception will be propagated immediately and action c wonÂ’t be executed.

Is that clear enough and simple enough?

Jon
Miha Markic (3) [Avatar] Offline
#3
Re: 2.1.2 and 3 a suggestion
Sounds ok to me.
Perhaps one more hint: it is better to override an OnXXX method (if one exists) than implementing XXX event within the same class (think Form) for both performance and this exception reasons.
This hint might be out of the scope though.
jon.skeet (483) [Avatar] Offline
#4
Re: 2.1.2 and 3 a suggestion
Yeah, I think that's a bit beyond the scope of the chapter. If I went into events in full, there's a lot that I could say - but it's really just a reminder chapter, primarily about delegates rather than events. Events don't change in C# 2/3, but delegates do smilie

Jon
Miha Markic (3) [Avatar] Offline
#5
Re: 2.1.2 and 3 a suggestion
Yes, agreed. It is just annoying seeing a lot of people implementing events rather than overriding equivalent methods.