Home > Archive > C# > February 2005 > Checking if EventHandlers are assigned?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Checking if EventHandlers are assigned?
|
|
| Kelly C 2005-02-23, 8:58 pm |
| I'm from the Delphi world slowly crossing into the C# world ...
Quick syntax question (I hope), Is there a C# equivalent for testing if an
event handler is assinged?
In delphi it would look something like this ...
if Assigned(Object.OnEvent) then
begin
//fire the event
end;
| |
| Richard 2005-02-23, 8:58 pm |
| I think (i'm not certain) that what your after is;
if (this.myEvent!= null)
{
}
At least something like that. The above should ensure that when you raise
an event, there is something wired-up on the otherside.
"Kelly C" <kelly.cromwell@synergisticbe.com> wrote in message
news:JL7Td.488309$8l.84623@pd7tw1no...
> I'm from the Delphi world slowly crossing into the C# world ...
>
> Quick syntax question (I hope), Is there a C# equivalent for testing if an
> event handler is assinged?
>
> In delphi it would look something like this ...
>
> if Assigned(Object.OnEvent) then
> begin
> //fire the event
> end;
>
>
| |
| MasterGaurav 2005-02-25, 8:58 am |
| It depends on how you've implemented the handlers.
If you are trying to get information of the list to the default
handlers (in .Net), mostly you'll not be able to do it.
But if it's your handler... yes.. defintiely you can.
Have you directly exposed the handler?
-- OR --
Are you using EventHandlerList class?
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------
|
|
|
|
|