Partager via


EventAttribute.Task Propriété

Définition

Obtient ou définit la tâche de l'événement.

public:
 property System::Diagnostics::Tracing::EventTask Task { System::Diagnostics::Tracing::EventTask get(); void set(System::Diagnostics::Tracing::EventTask value); };
public System.Diagnostics.Tracing.EventTask Task { get; set; }
member this.Task : System.Diagnostics.Tracing.EventTask with get, set
Public Property Task As EventTask

Valeur de propriété

Tâche de l’événement.

Exemples

L’exemple suivant montre comment utiliser la propriété pour définir des Task tâches d’événement. Cet exemple de code fait partie d’un exemple plus grand fourni pour la EventSource classe .

public static class Tasks
{
    public const EventTask Page = (EventTask)1;
    public const EventTask DBQuery = (EventTask)2;
}
Public Class Tasks
    Public Const Page As EventTask = CType(1, EventTask)
    Public Const DBQuery As EventTask = CType(1, EventTask)
End 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
[Event(5, Opcode = EventOpcode.Start, Task = Tasks.DBQuery, Keywords = Keywords.DataBase, Level = EventLevel.Informational)]
public void DBQueryStart(string sqlQuery) { WriteEvent(5, sqlQuery); }
<[Event](5, Opcode:=EventOpcode.Start, Task:=Tasks.DBQuery, Keywords:=Keywords.DataBase, Level:=EventLevel.Informational)> _
Public Sub DBQueryStart(ByVal sqlQuery As String)
    WriteEvent(5, sqlQuery)
End Sub

S’applique à