|
tech
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Detect if an event has event handlerHi,
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 >Is there any way to detect if I already bound a handler to the event The easiest way is to just keep track of that in a boolean field.>(to not bind the handler several times) Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. On 18 Noi, 16:51, Mattias Sjögren <mattias.dont.want.s***@mvps.org>
wrote: > >Is there any way to detect if I already bound a handler to the event I thought maybe it is a more elegant way> >(to not bind the handler several times) > > The easiest way is to just keep track of that in a boolean field. Thanks 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" <bzam***@gmail.com> wrote in message On 18 Noi, 16:51, Mattias Sjögren <mattias.dont.want.s***@mvps.org>news:58cc3ccf-7b76-4cd2-9edd-ef0eb89675eb@b15g2000hsa.googlegroups.com... wrote: > >Is there any way to detect if I already bound a handler to the event I thought maybe it is a more elegant way> >(to not bind the handler several times) > > The easiest way is to just keep track of that in a boolean field. Thanks >if you attach the same handler from the same object instance twice, it will No, it will be called once for each time you add it.>still be only called once. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. |
|||||||||||||||||||||||