[Mono-list] Little question ...

Nick Berardi nberardi@zigamorph.com
Thu, 19 Feb 2004 15:13:50 -0500


Events are more like delegate properties.  Such is you can do the =
This is good if you want to encapsulate a child objects event.  Such as =
I am doing it below.  When somebody calls the following:

myObject.RightListItemChanged +=3D new EventHandler =

this is what happens underneath in the code.  It sets the child objects
SelectedItemChange to the method that I selected above.  Even though it =
twice removed.  In addition it enabled AutoPostBack.

public event EventHandler RightListItemChanged {
		deniedListBox.SelectedIndexChanged +=3D value;=20
		deniedListBox.AutoPostBack =3D true;
		deniedListBox.SelectedIndexChanged -=3D value;
		deniedListBox.AutoPostBack =3D false;

-----Original Message-----
From: mono-list-admin@lists.ximian.com
[mailto:mono-list-admin@lists.ximian.com] On Behalf Of Sergio Blanco
Sent: Thursday, February 19, 2004 2:56 PM
To: mono-list@lists.ximian.com
Subject: Re: [Mono-list] Little question ...

El s=E1b, 07-02-2004 a las 17:21, Miguel de Icaza escribi=F3:
> Hey,
> > Only one little question: What are the main differences between =
> > "event" keyword or not when creating delegates?
> >=20
> > Example:
> >=20
> > delegate void ProbeDelegate  (string msg);
> >=20
> > ProbeDelegate d1;
> > event ProbeDelegate d2;
> events can notify more than one function, a delegate only points to a
> single method.
> So you can have multiple "listeners".

But, only using delegates you can do:

  DelegadoOperacion multiD;
  multiD =3D new DelegadoOperacion(s.suma);
  multiD +=3D new DelegadoOperacion(s.resta);

And then call multiD which will call more than one method. So what is
the real difference with events ??



[aka Marble]
 Web Personal  <>  http://www.marblestation.com
 Registered LiNUX user #140941  <>  http://counter.li.org/
 Socio #3274 de HispaLinux  <>  http://www.hispalinux.es
 Miembro de GPL URV  <>  http://www.gplurv.org
 GnuPG key: 0x0ED2CF9D  <>  hkp://pgp.escomposlinux.org