views:

68

answers:

2

my previos question is how to clear event handles in c#

Now i need to know that how to check any event handler already assigned?

A: 

Unless I misunderstand the question, a simple check for null should be sufficient. You always need to check for a null in the event handler anyway before calling any event handlers.

Cylon Cat
How to check using null. i'm using like this `if(client.getPagesCompleted ==null)` but error shown.
ebattulga
A little more context would help. How is getPagesCompleted declared?
Cylon Cat
A: 

If the event is in the same class where you will do the check, you can compare to null. But if this is not the case, you should ask yourself why do you care about the inside workings of a class. I mean it is the job of the class which contains the event to care about its subscribers not the opposite. But if you really want this information, the event containing class can expose a property for the outside world - like HasEventHandlers.

Petar Minchev