TraceContextEventHandler Delegate
.NET Framework 3.0
Represents the method that handles the TraceFinished event of a TraceContext object.
Namespace: System.Web
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
'Declaration Public Delegate Sub TraceContextEventHandler ( _ sender As Object, _ e As TraceContextEventArgs _ ) 'Usage Dim instance As New TraceContextEventHandler(AddressOf HandlerMethod)
/** @delegate */ public delegate void TraceContextEventHandler ( Object sender, TraceContextEventArgs e )
Not applicable.
Parameters
- sender
The event source (the TraceContext).
- e
A TraceContextEventArgs that contains the event data.
When you create a TraceContextEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.
For more information about event handler delegates, see Events and Delegates.
The following code example demonstrates how to register a TraceContextEventHandler delegate to handle the TraceFinished event. In this example, the OnTraceFinished method iterates through the trace records and writes them to the response stream.
<%@ Page language="VB" Trace="true" %> <script runat="server"> ' The Page_Load method. Private Sub Page_Load(sender As Object, e As EventArgs) ' Register a handler for the TraceFinished event. AddHandler Trace.TraceFinished, AddressOf OnTraceFinished ' Write a trace message. Trace.Write("Web Forms Infrastructure Methods", "USERMESSAGE: Page_Load complete.") End Sub ' Page_Load ' A TraceContextEventHandler for the TraceFinished event. Private Sub OnTraceFinished(sender As Object, e As TraceContextEventArgs) Dim r As TraceContextRecord Dim o As Object ' Iterate through the collection of trace records and write ' them to the response stream. For Each o In e.TraceRecords r = CType(o, TraceContextRecord) Response.Write(String.Format("trace message: {0} <BR>", r.Message)) Next End Sub ' OnTraceFinished </script>
Community Additions
ADD
Show: