Is it possible to check if there is a handler registered for one of my events?

  • Thread starter Thread starter Andreas =?ISO-8859-1?Q?M=FCller?=
  • Start date Start date
A

Andreas =?ISO-8859-1?Q?M=FCller?=

Hi,

I have a class that provides an event.

Class Test
Public Event MyEvent(ByVal iExpensiveParameter As Integer)
End Class

The problem is, that when the event is raised, a lot of expensive
computation has to be done to calculate the parameter of the event. So I
only would like to do that, if anybody has registered a handler for this
event. Is it possible to find that out?
Thanks in advance,
Andy
 
Andreas Müller said:
I have a class that provides an event.

Class Test
Public Event MyEvent(ByVal iExpensiveParameter As Integer)
End Class

The problem is, that when the event is raised, a lot of expensive
computation has to be done to calculate the parameter of the event. So I
only would like to do that, if anybody has registered a handler for this
event. Is it possible to find that out?

If Not MyEventEvent Is Nothing Then
'expensive computation
RaiseEvent MyEvent(...)
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top