Uredi

Deli z drugimi prek


EventSource.WriteEvent Method

Definition

Writes an event by using the provided event identifier and optional arguments.

Overloads

WriteEvent(Int32, String, String, String)

Writes an event by using the provided event identifier and string arguments.

WriteEvent(Int32, String, Int32, Int32)

Writes an event by using the provided event identifier and arguments.

WriteEvent(Int32, Int64, Int64, Int64)

Writes an event by using the provided event identifier and 64-bit arguments.

WriteEvent(Int32, Int32, Int32, Int32)

Writes an event by using the provided event identifier and 32-bit integer arguments.

WriteEvent(Int32, String, String)

Writes an event by using the provided event identifier and string arguments.

WriteEvent(Int32, String, Int64)

Writes an event by using the provided event identifier and arguments.

WriteEvent(Int32, String, Int32)

Writes an event by using the provided event identifier and arguments.

WriteEvent(Int32, Int64, String)

Writes an event by using the provided event identifier and 64-bit integer, and string arguments.

WriteEvent(Int32, Int64, Int64)

Writes an event by using the provided event identifier and 64-bit arguments.

WriteEvent(Int32, Int32, Int32)

Writes an event by using the provided event identifier and 32-bit integer arguments.

WriteEvent(Int32, Int32, String)

Writes an event by using the provided event identifier and 32-bit integer and string arguments.

WriteEvent(Int32, String)

Writes an event by using the provided event identifier and string argument.

WriteEvent(Int32, Object[])

Writes an event by using the provided event identifier and array of arguments.

WriteEvent(Int32, Int64)

Writes an event by using the provided event identifier and 64-bit integer argument.

WriteEvent(Int32, Int32)

Writes an event by using the provided event identifier and 32-bit integer argument.

WriteEvent(Int32, EventSource+EventSourcePrimitive[])

Writes an event by using the provided event identifier and a variable number of event source primitives.

WriteEvent(Int32, Byte[])

Writes an event by using the provided event identifier and byte array argument.

WriteEvent(Int32)

Writes an event by using the provided event identifier.

WriteEvent(Int32, Int64, Byte[])

Writes the event data using the specified identifier and 64-bit integer and byte array arguments.

Remarks

The WriteEvent method provides overloads with combinations of string and integer arguments. If none of these combinations match the parameters for the call, the compiler uses the EventSource.WriteEvent(Int32, Object[]) overload, which is considerably slower than the other overloads. See the overload page for details.

In all cases, the eventid parameter should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

You can also create a custom overload by using the WriteEventCore method.

Important

Event parameters with a type of string should not include \0 characters. They are unsupported characters and can cause issues for parsers of the event payload.

WriteEvent(Int32, String, String, String)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and string arguments.

protected:
 void WriteEvent(int eventId, System::String ^ arg1, System::String ^ arg2, System::String ^ arg3);
protected void WriteEvent (int eventId, string arg1, string arg2, string arg3);
protected void WriteEvent (int eventId, string? arg1, string? arg2, string? arg3);
member this.WriteEvent : int * string * string * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As String, arg3 As String)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
String

A string argument.

arg2
String

A string argument.

arg3
String

A string argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, String, Int32, Int32)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and arguments.

protected:
 void WriteEvent(int eventId, System::String ^ arg1, int arg2, int arg3);
protected void WriteEvent (int eventId, string arg1, int arg2, int arg3);
protected void WriteEvent (int eventId, string? arg1, int arg2, int arg3);
member this.WriteEvent : int * string * int * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As Integer, arg3 As Integer)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
String

A string argument.

arg2
Int32

A 32 bit integer argument.

arg3
Int32

A 32 bit integer argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Int64, Int64, Int64)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and 64-bit arguments.

protected:
 void WriteEvent(int eventId, long arg1, long arg2, long arg3);
protected void WriteEvent (int eventId, long arg1, long arg2, long arg3);
member this.WriteEvent : int * int64 * int64 * int64 -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long, arg2 As Long, arg3 As Long)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int64

A 64 bit integer argument.

arg2
Int64

A 64 bit integer argument.

arg3
Int64

A 64 bit integer argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Int32, Int32, Int32)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and 32-bit integer arguments.

protected:
 void WriteEvent(int eventId, int arg1, int arg2, int arg3);
protected void WriteEvent (int eventId, int arg1, int arg2, int arg3);
member this.WriteEvent : int * int * int * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Integer, arg2 As Integer, arg3 As Integer)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int32

An integer argument.

arg2
Int32

An integer argument.

arg3
Int32

An integer argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, String, String)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and string arguments.

protected:
 void WriteEvent(int eventId, System::String ^ arg1, System::String ^ arg2);
protected void WriteEvent (int eventId, string arg1, string arg2);
protected void WriteEvent (int eventId, string? arg1, string? arg2);
member this.WriteEvent : int * string * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As String)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
String

A string argument.

arg2
String

A string argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, String, Int64)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and arguments.

protected:
 void WriteEvent(int eventId, System::String ^ arg1, long arg2);
protected void WriteEvent (int eventId, string arg1, long arg2);
protected void WriteEvent (int eventId, string? arg1, long arg2);
member this.WriteEvent : int * string * int64 -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As Long)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
String

A string argument.

arg2
Int64

A 64 bit integer argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, String, Int32)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and arguments.

protected:
 void WriteEvent(int eventId, System::String ^ arg1, int arg2);
protected void WriteEvent (int eventId, string arg1, int arg2);
protected void WriteEvent (int eventId, string? arg1, int arg2);
member this.WriteEvent : int * string * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String, arg2 As Integer)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
String

A string argument.

arg2
Int32

A 32 bit integer argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Int64, String)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and 64-bit integer, and string arguments.

protected:
 void WriteEvent(int eventId, long arg1, System::String ^ arg2);
protected void WriteEvent (int eventId, long arg1, string arg2);
protected void WriteEvent (int eventId, long arg1, string? arg2);
member this.WriteEvent : int * int64 * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long, arg2 As String)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int64

A 64-bit integer argument.

arg2
String

A string argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(Int64 arg1, string arg2)
{
    base.WriteEvent(2, arg1, arg2);
}

Applies to

WriteEvent(Int32, Int64, Int64)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and 64-bit arguments.

protected:
 void WriteEvent(int eventId, long arg1, long arg2);
protected void WriteEvent (int eventId, long arg1, long arg2);
member this.WriteEvent : int * int64 * int64 -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long, arg2 As Long)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int64

A 64 bit integer argument.

arg2
Int64

A 64 bit integer argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Int32, Int32)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and 32-bit integer arguments.

protected:
 void WriteEvent(int eventId, int arg1, int arg2);
protected void WriteEvent (int eventId, int arg1, int arg2);
member this.WriteEvent : int * int * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Integer, arg2 As Integer)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int32

An integer argument.

arg2
Int32

An integer argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(int arg1, int arg2, int arg3)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Int32, String)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and 32-bit integer and string arguments.

protected:
 void WriteEvent(int eventId, int arg1, System::String ^ arg2);
protected void WriteEvent (int eventId, int arg1, string arg2);
protected void WriteEvent (int eventId, int arg1, string? arg2);
member this.WriteEvent : int * int * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Integer, arg2 As String)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int32

A 32-bit integer argument.

arg2
String

A string argument.

Applies to

WriteEvent(Int32, String)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and string argument.

protected:
 void WriteEvent(int eventId, System::String ^ arg1);
protected void WriteEvent (int eventId, string arg1);
protected void WriteEvent (int eventId, string? arg1);
member this.WriteEvent : int * string -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As String)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
String

A string argument.

Examples

The following example shows how to use this method overload to write an event. This code example is part of a larger example provided for the EventSource class.

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }
<[Event](1, Message:="Application Failure: {0}", Level:=EventLevel.Error, Keywords:=Keywords.Diagnostic)> _
Public Sub Failure(ByVal message As String)
    WriteEvent(1, message)
End Sub

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Object[])

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and array of arguments.

protected:
 void WriteEvent(int eventId, ... cli::array <System::Object ^> ^ args);
protected void WriteEvent (int eventId, params object[] args);
protected void WriteEvent (int eventId, params object?[] args);
member this.WriteEvent : int * obj[] -> unit
Protected Sub WriteEvent (eventId As Integer, ParamArray args As Object())

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

args
Object[]

An array of objects.

Remarks

By default, the compiler calls this overload if the parameters for the call do not match one of the other method overloads. This overload is much slower than the other overloads, because it does the following:

  1. It allocates an array to hold the variable argument.

  2. It casts each parameter to an object (which causes allocations for primitive types).

  3. It assigns these objects to the array.

  4. It calls the function, which then determines the type of each argument so it can be serialized for ETW.

The high overhead for this overload is not significant when tracing low-volume events, because the method is used only when the provider is enabled. However, for high-volume events, the performance overhead can be significant. You can avoid using EventSource.WriteEvent for high-volume payloads by creating a new, faster overload with the WriteEventCore method.

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Int64)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and 64-bit integer argument.

protected:
 void WriteEvent(int eventId, long arg1);
protected void WriteEvent (int eventId, long arg1);
member this.WriteEvent : int * int64 -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int64

A 64 bit integer argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Int32)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and 32-bit integer argument.

protected:
 void WriteEvent(int eventId, int arg1);
protected void WriteEvent (int eventId, int arg1);
member this.WriteEvent : int * int -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Integer)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int32

An integer argument.

Examples

The following example shows how to use this method overload to write an event. This code example is part of a larger example provided for the EventSource class.

[Event(4, Opcode = EventOpcode.Stop, Task = Tasks.Page, Keywords = Keywords.Page, Level = EventLevel.Informational)]
public void PageStop(int ID) { if (IsEnabled()) WriteEvent(4, ID); }
<[Event](4, Opcode:=EventOpcode.Stop, Task:=Tasks.Page, Keywords:=Keywords.Page, Level:=EventLevel.Informational)> _
Public Sub PageStop(ByVal ID As Integer)
    If IsEnabled() Then
        WriteEvent(4, ID)
    End If
End Sub

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(int  arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, EventSource+EventSourcePrimitive[])

Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and a variable number of event source primitives.

protected:
 void WriteEvent(int eventId, ... cli::array <System::Diagnostics::Tracing::EventSource::EventSourcePrimitive> ^ args);
protected void WriteEvent (int eventId, params System.Diagnostics.Tracing.EventSource.EventSourcePrimitive[] args);
member this.WriteEvent : int * System.Diagnostics.Tracing.EventSource.EventSourcePrimitive[] -> unit
Protected Sub WriteEvent (eventId As Integer, ParamArray args As EventSource.EventSourcePrimitive())

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

args
EventSource.EventSourcePrimitive[]

The event source primitives.

Remarks

This is a varargs helper for writing an event. It does create an array and box all the arguments so it is relatively inefficient and should only be used for relatively rare events (for example, less than 100 per second). If your rates are faster than that, use WriteEventCore(Int32, Int32, EventSource+EventData*) to create fast helpers for your particular method signature. Even if you use this for rare events, this call should be guarded by an IsEnabled() check so that the varargs call is not made when the EventSource isn't active.

Applies to

WriteEvent(Int32, Byte[])

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier and byte array argument.

protected:
 void WriteEvent(int eventId, cli::array <System::Byte> ^ arg1);
protected void WriteEvent (int eventId, byte[] arg1);
protected void WriteEvent (int eventId, byte[]? arg1);
member this.WriteEvent : int * byte[] -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Byte())

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Byte[]

A byte array argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(byte[] arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32)

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes an event by using the provided event identifier.

protected:
 void WriteEvent(int eventId);
protected void WriteEvent (int eventId);
member this.WriteEvent : int -> unit
Protected Sub WriteEvent (eventId As Integer)

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

Examples

The following example shows how to use this method overload to write an event. This code example is part of a larger example provided for the EventSource class.

[Event(1, Message = "Application Failure: {0}", Level = EventLevel.Error, Keywords = Keywords.Diagnostic)]
public void Failure(string message) { WriteEvent(1, message); }
<[Event](1, Message:="Application Failure: {0}", Level:=EventLevel.Error, Keywords:=Keywords.Diagnostic)> _
Public Sub Failure(ByVal message As String)
    WriteEvent(1, message)
End Sub

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(string arg1)
{
    base.WriteEvent(2, arg1);
}

Applies to

WriteEvent(Int32, Int64, Byte[])

Source:
EventSource.cs
Source:
EventSource.cs
Source:
EventSource.cs

Writes the event data using the specified identifier and 64-bit integer and byte array arguments.

protected:
 void WriteEvent(int eventId, long arg1, cli::array <System::Byte> ^ arg2);
protected void WriteEvent (int eventId, long arg1, byte[] arg2);
protected void WriteEvent (int eventId, long arg1, byte[]? arg2);
member this.WriteEvent : int * int64 * byte[] -> unit
Protected Sub WriteEvent (eventId As Integer, arg1 As Long, arg2 As Byte())

Parameters

eventId
Int32

The event identifier. This value should be between 0 and 65535.

arg1
Int64

A 64-bit integer argument.

arg2
Byte[]

A byte array argument.

Remarks

eventid should be greater than 0 or less than 65535 or errors can occur in the operation. If errors do occur, you can get more information about the source of the error by checking the output stream of the debugger, if you have a debugger attached to the process firing events. You can also look for errors reported in the ETW event stream, if you have an ETW listener on the event source where the error occurs.

When you implement a method that is identified as an ETW event in an EventSource-derived class. You must call the base class WriteEvent method passing the EventId and the same arguments as the implemented method similar to the following example.

[Event(2, Level = EventLevel.Informational)]
public void Info1(Int64 arg1, Byte[] arg2)
{
    base.WriteEvent(2, arg1, arg2);
}

Applies to