Using a signature like
(Sender as Object, e as ChanelFoundEventArgs)
where ChanelFoundEventArgs inherits of EventArgs is a good convention
although not strictly neccesery.
To solve your polymorpism problem you should use interfaces.
Define an interface Like:
Code:
Public Interface IChannelFound
Event ChannelFound(ByVal sender As Object, ByVal e As ChannelFoundEventArgs)
End Interface
To make the new eventArgs do someting like this:
Code:
Public Class ChannelFoundEventArgs
Inherits EventArgs
Private _ChannelNumber As Integer
Property ChannelFound() As Integer
Get
Return _ChannelNumber
End Get
Set(ByVal value As Integer)
_ChannelNumber = value
End Set
End Property
End Class
Now you can use the interface for several classes, this ensures the signature is correct:
Code:
Public Class X
Implements IChannelFound
Public Event ChannelFound(ByVal sender As Object, ByVal e As ChannelFoundEventArgs) Implements IChannelFound.ChannelFound
Sub SomeSub()
Dim e As New ChannelFoundEventArgs
e.ChannelFound = 56928
RaiseEvent ChannelFound(Me, e)
End Sub
End Class
Public Class Y
Implements IChannelFound
Public Event ChannelFound(ByVal sender As Object, ByVal e As ChannelFoundEventArgs) Implements IChannelFound.ChannelFound
Sub SomeSub()
Dim e As New ChannelFoundEventArgs
e.ChannelFound = 1111
RaiseEvent ChannelFound(Me, e)
End Sub
End Class
The other benefit is the posibility to cast these classes to the IChannelFound Interface, regardless of the fact that it is a type X class or Type Y class