Detect if an event has event handler

Detect if an event has event handler

am 18.11.2007 13:09:56 von BZ

Hi,

I need to bind the dropdown event to an event handler, but not from
beginning (in form's load or constructor), but little bit later, when
a background process completes.

Is there any way to detect if I already bound a handler to the event
(to not bind the handler several times)

Thank you

Re: Detect if an event has event handler

am 18.11.2007 15:51:36 von mattias.dont.want.spam

>Is there any way to detect if I already bound a handler to the event
>(to not bind the handler several times)

The easiest way is to just keep track of that in a boolean field.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: Detect if an event has event handler

am 18.11.2007 16:47:53 von BZ

On 18 Noi, 16:51, Mattias Sjögren
wrote:
> >Is there any way to detect if I already bound a handler to the event
> >(to not bind the handler several times)
>
> The easiest way is to just keep track of that in a boolean field.

I thought maybe it is a more elegant way

Thanks

Re: Detect if an event has event handler

am 18.11.2007 16:55:45 von newsgroups_remove

Hi,

if you attach the same handler from the same object instance twice, it will
still be only called once.

Kind regards,
Henning Krause



"bz" wrote in message
news:58cc3ccf-7b76-4cd2-9edd-ef0eb89675eb@b15g2000hsa.google groups.com...
On 18 Noi, 16:51, Mattias Sjögren
wrote:
> >Is there any way to detect if I already bound a handler to the event
> >(to not bind the handler several times)
>
> The easiest way is to just keep track of that in a boolean field.

I thought maybe it is a more elegant way

Thanks

Re: Detect if an event has event handler

am 18.11.2007 20:42:54 von mattias.dont.want.spam

>if you attach the same handler from the same object instance twice, it will
>still be only called once.

No, it will be called once for each time you add it.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: Detect if an event has event handler

am 19.11.2007 06:55:15 von notmyfirstname

bz.

ind in files.

An event method can as well be used without an event.

Cor