From: Tony Johansson on
Hi!

Is it possible to rewrite this code in such a way
that I get something like
event AlarmEventHandler myEvent;
I'm not so used to code when it is written in this way.

//Here is the Code
If AlarmEventArgs e = new AlarmEventArgs(1,2);
AlarmEventHandler handler = Alarm;

if (handler != null)
{
handler(this, e);
}

//Tony


From: "Roger" rjpd AT NOnetzeroSPAM DOT on
public event AlarmEventHandler myEvent;

The subscriber should:
myEvent += MyHandler;

Then the publisher should call it when appropriate:
if (myEvent != null)
{
AlarmEventArgs e = new AlarmEventArgs(1,2);
myEevent(this, e);
}

I think this is about it, not tested though.
Roger



> I'm not so used to code when it is written in this way.
>
> //Here is the Code
> If AlarmEventArgs e = new AlarmEventArgs(1,2);
> AlarmEventHandler handler = Alarm;
>
> if (handler != null)
> {
> handler(this, e);
> }
>
> //Tony
>