Ok I have a class that I want to handle it's own events but still have the instance inherit it.
for instance I want the event to display in a text box but from class level.
Make sense?
Here's my code:
vb.net Code:
Private Sub InitializeHandlers() AddHandler Me.OnConnectionEvent, AddressOf OnConnection 'AddHandler Me.OnAuthentication, AddressOf OnAuthenticated End Sub Public Function OnConnection(ByVal sender As Object, ByVal e As ConnectionEventArgs) Return e.ConnectionData & vbCrLf End Function Public Sub Connect() clientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Dim endpoint As IPEndPoint = New IPEndPoint(Dns.GetHostEntry(_remoteHostIP).AddressList(0), _remotePort) Try clientSocket.Connect(endpoint) If clientSocket.Connected = True Then RaiseEvent OnConnectionEvent(Me, New ConnectionEventArgs(True)) End If Catch ex As SocketException RaiseEvent OnConnectionEvent(Me, New ConnectionEventArgs(False, ex.Message)) 'Console.Write(ex.Message) End Try End Sub Public Class ConnectionEventArgs Inherits TcpEventArgs #Region "Decelartions" Private _connected As Boolean Private _data As String #End Region #Region "Constructors" Public Sub New(ByVal connected As Boolean) MyBase.New(-1, "") _connected = connected End Sub Public Sub New(ByVal connected As Boolean, ByVal data As String) MyBase.New(-1, "") _connected = connected _data = data End Sub #End Region #Region "Properties" Public ReadOnly Property Connected() As Boolean Get Return _connected End Get End Property Public ReadOnly Property ConnectionData() As String Get Return _data End Get End Property #End Region End Class




Reply With Quote