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.
I'd suggest a custom Event Arguments class to which you add a Handled
property. Pass this along with your Event and, if the Handled property
comes back False ...
Public Class CustomEventArgs
Inherits EventArgs
Friend Sub New()
End Sub
Public Property Handled() as Boolean
Get
Return m_bHandled
End Get
Set( Value as Boolean )
m_bHandled = Value
End Set
End Property
Private m_bHandled = False
End Class
Public Event SomeEvent( _
ByVal sender As Object _
, ByVal e As CustomEventArgs _
)
Protected Sub OnSomeEvent()
Dim e as New CustomEventArgs
RaiseEvent SomeEvent( Me, e )
If e.Handled = False Then
Throw New YouDidntHandleMyEventException( ...
End If
End Sub
HTH,
Phill W.