K
Krzysztof Malinowski
Hi,
We can raise an event by calling some method the same
like a delegate. Actually one event can reference a few
different method each of these meets delegate declaration.
Like below:
(...)
clock.Alarm += new AlarmEventHandler(w.AlarmRang);
(...)
where clock.Alarm is an event.
My question is woh can I only in one step call all of
these event handlers, like below:
(...)
protected virtual void OnAlarm(AlarmEventArgs e)
{
if (Alarm != null)
{
// Invokes the delegates.
Alarm(this, e);
}
}
(...)
By calling Alarm(this, e), we actually calling all
handlers.
For me it's a little strange, I think in this way we can
call only last referenced handler. So, I'm used to think
in C++ (pointers) way.
Regards
Krzysztof
We can raise an event by calling some method the same
like a delegate. Actually one event can reference a few
different method each of these meets delegate declaration.
Like below:
(...)
clock.Alarm += new AlarmEventHandler(w.AlarmRang);
(...)
where clock.Alarm is an event.
My question is woh can I only in one step call all of
these event handlers, like below:
(...)
protected virtual void OnAlarm(AlarmEventArgs e)
{
if (Alarm != null)
{
// Invokes the delegates.
Alarm(this, e);
}
}
(...)
By calling Alarm(this, e), we actually calling all
handlers.
For me it's a little strange, I think in this way we can
call only last referenced handler. So, I'm used to think
in C++ (pointers) way.
Regards
Krzysztof