G
Gene Wirchenko
Dear C-Sharpies:
I am studying Wrox's "Professional C# 3rd Edition" by Robinson et
al. Chapter 6 (Delegates and Events) is a tough slog.
On page 179, it ends the Multicast Delegates section with "If you
are using multicast delegates, you should be aware that the order in
which methods chained the same delgate will be called is formally
undefined. You should, therefore, avoid writing code that relies on
such methods being called in any particular order."
The next section is Events. One of the buttons in the sample
code has two methods called
btnTwo.Click+=new EventHandler(Button_Click);
btnTwo.Click+=new EventHandler(btnTwo_Click);
Button_Click() indicates which button was clicked. btnTwo_Click()
pops up a message box.
IIUC, the p. 179 caveat quoted above applies.
It could well matter which order the methods are called in, and
C# is supposedly a professional language so it ought to be possible to
specify the order. If the order does matter, how does one code for
it?
Or am I missing something?
Sincerely,
Gene Wirchenko
I am studying Wrox's "Professional C# 3rd Edition" by Robinson et
al. Chapter 6 (Delegates and Events) is a tough slog.
On page 179, it ends the Multicast Delegates section with "If you
are using multicast delegates, you should be aware that the order in
which methods chained the same delgate will be called is formally
undefined. You should, therefore, avoid writing code that relies on
such methods being called in any particular order."
The next section is Events. One of the buttons in the sample
code has two methods called
btnTwo.Click+=new EventHandler(Button_Click);
btnTwo.Click+=new EventHandler(btnTwo_Click);
Button_Click() indicates which button was clicked. btnTwo_Click()
pops up a message box.
IIUC, the p. 179 caveat quoted above applies.
It could well matter which order the methods are called in, and
C# is supposedly a professional language so it ought to be possible to
specify the order. If the order does matter, how does one code for
it?
Or am I missing something?
Sincerely,
Gene Wirchenko