Take a look at custom events--you can use them to take control of
the process. In your code for the RaiseEvent method you could
check if there are any subscribers before actually firing the
event. For example:
Private _Test As EventHandler
Public Custom Event Test As EventHandler
AddHandler(ByVal value As EventHandler)
_Test = DirectCast([Delegate].Combine(_Test, value), EventHandler)
End AddHandler
RemoveHandler(ByVal value As EventHandler)
_Test = DirectCast([Delegate].Remove(_Test, value), EventHandler)
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
If _Test IsNot Nothing Then
_Test.Invoke(sender, e)
End If
End RaiseEvent
End Event
J
<ee******@gmail.comwrote in message
news:11*********************@o61g2000hsh.googlegro ups.com...
Is there a way to force the consumer of my object to handle events
that I've fired off? I don't care how they handle the event, just that
they do. I think in c# there is a way but not sure about vb.net.
Please advise.