TraceContextEventHandler TraceContextEventHandler TraceContextEventHandler TraceContextEventHandler Delegate

정의

TraceFinished 개체의 TraceContext 이벤트를 처리하는 메서드를 나타냅니다.Represents the method that handles the TraceFinished event of a TraceContext object.

public delegate void TraceContextEventHandler(System::Object ^ sender, TraceContextEventArgs ^ e);
public delegate void TraceContextEventHandler(object sender, TraceContextEventArgs e);
type TraceContextEventHandler = delegate of obj * TraceContextEventArgs -> unit
Public Delegate Sub TraceContextEventHandler(sender As Object, e As TraceContextEventArgs)

매개 변수

sender
Object Object Object Object

이벤트 소스(TraceContext)입니다.The event source (the TraceContext).

e
TraceContextEventArgs TraceContextEventArgs TraceContextEventArgs TraceContextEventArgs

이벤트 데이터를 포함하는 TraceContextEventArgs입니다.A TraceContextEventArgs that contains the event data.

상속
TraceContextEventHandlerTraceContextEventHandlerTraceContextEventHandlerTraceContextEventHandler

예제

다음 코드 예제에는 등록 하는 방법을 보여 줍니다.는 TraceContextEventHandler 처리 하는 대리자는 TraceFinished 이벤트입니다.The following code example demonstrates how to register a TraceContextEventHandler delegate to handle the TraceFinished event. 이 예제는 OnTraceFinished 메서드는 추적 레코드를 반복 하 고 응답 스트림에 씁니다.In this example, the OnTraceFinished method iterates through the trace records and writes them to the response stream.

<%@ Page language="c#" Trace="true" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
    // Register a handler for the TraceFinished event.
    Trace.TraceFinished += new 
        TraceContextEventHandler(this.OnTraceFinished);

    // Write a trace message.
    Trace.Write("Web Forms Infrastructure Methods", "USERMESSAGE: Page_Load complete.");
}
 
// A TraceContextEventHandler for the TraceFinished event.
void OnTraceFinished(object sender, TraceContextEventArgs e)
{
    TraceContextRecord r = null;    
    
    // Iterate through the collection of trace records and write 
    // them to the response stream.
    foreach(object o in e.TraceRecords)
    {
        r = (TraceContextRecord)o;
        Response.Write(String.Format("trace message: {0} <BR>", r.Message));
    }
}       
</script>
<%@ 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>

설명

TraceContextEventHandler 대리자를 만들 때, 이벤트를 처리할 메서드를 식별합니다.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 Handling and Raising Events.

확장 메서드

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.Gets an object that represents the method represented by the specified delegate.

적용 대상

추가 정보