Using Instrumentation

Apr 8, 2008 at 1:53 PM
Edited Apr 9, 2008 at 12:21 PM
I have created a Provider and Listener Class (console project) in order to learn about the instrumentation features.

However, my code does not enter the handler in my Listener class at all.

Below is my code.

I really would appreciate any help on this.

Kind regards,

Polly Anna

The Provider Class -

Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports System.Data
Imports System.Data.Common
Imports Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation

<InstrumentationListener(GetType(CListener))> _
Public Class CProvider

Public Sub GetDataFromDB()

' do work here


' all the work is routine code is put here

' Raise an event here as have just connected to the db
RaiseEvent ConnectedToDB("Have just opened a connection")

Catch ex As Exception
End Try

End Sub

The Listener class -

mports Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation

Public Class CListener

' This is the event handler for the EL instrumentation
<InstrumentationConsumer("DBConnect")> _
Public Sub RespondToProviderEvent(ByVal sender As Object, _
ByVal e As EventArgs)

Console.WriteLine("A connection has been made to the Db" )

End Sub

End Class