This documentation is archived and is not being maintained.

EntryWrittenEventArgs Class

Provides data for the EntryWritten event.

For a list of all members of this type, see EntryWrittenEventArgs Members.


[Visual Basic]
Public Class EntryWrittenEventArgs
   Inherits EventArgs
public class EntryWrittenEventArgs : EventArgs
public __gc class EntryWrittenEventArgs : public EventArgs
public class EntryWrittenEventArgs extends EventArgs

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


[Visual Basic, C#, C++] The following example demonstrates the EntryWrittenEventArgs constructor. It creates a custom EventLog object and writes an entry into it. Then it creates an EntryWrittenEventArgs object using the first entry in the custom EventLog. This object is used to notify a message.

[Visual Basic] 
Imports System
Imports System.Diagnostics

Class MySample
   Public Shared Sub Main()
         Dim myNewLog As New EventLog()
         myNewLog.Log = "MyNewLog"
         myNewLog.Source = "MySource"
         ' Create the source if it does not exist already.
         If Not EventLog.SourceExists("MySource") Then
            EventLog.CreateEventSource("MySource", "MyNewLog")
         End If
         ' Write an entry to the EventLog.
         myNewLog.WriteEntry("The Latest entry in the Event Log")
         Dim myEntryEventArgs As EntryWrittenEventArgs = _
                                    New EntryWrittenEventArgs()
         MyOnEntry(myNewLog, myEntryEventArgs)
      Catch e As Exception
         Console.WriteLine("Exception Raised" + e.Message)
      End Try
   End Sub 'Main
   Protected Shared Sub MyOnEntry(ByVal source As Object, _
                                  ByVal e As EntryWrittenEventArgs)
      If e.Entry Is Nothing Then
          Console.WriteLine("A new entry is written in MyNewLog.")
      End If
   End Sub 'MyOnEntry
End Class 'MySample

using System;
using System.Diagnostics;

   class MySample
      public static void Main()
            EventLog myNewLog = new EventLog();
            myNewLog.Log = "MyNewLog";
            // Create the source if it does not exist already.
               EventLog.CreateEventSource("MySource", "MyNewLog");
               // Write an entry to the EventLog.
               myNewLog.WriteEntry("The Latest entry in the Event Log");
            int myEntries = myNewLog.Entries.Count;
            EventLogEntry entry =myNewLog.Entries[myEntries-1];
            EntryWrittenEventArgs myEntryEventArgs=
                                 new EntryWrittenEventArgs();
         catch(Exception e)
            Console.WriteLine("Exception Raised" +e.Message);
      protected static void MyOnEntry(Object source, EntryWrittenEventArgs e)
         if(e.Entry == null)
            Console.WriteLine("A new entry is written in MyNewLog.");

#using <mscorlib.dll>
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

void MyOnEntry(Object* source, EntryWrittenEventArgs* e) {
        Console::WriteLine(S"A new entry is written in MyNewLog.");

int main() {
    try {
        EventLog* myNewLog = new EventLog();
        myNewLog->Log = S"MyNewLog";
        myNewLog->Source = S"MySource";
        // Create the source if it does not exist already.
        if (!EventLog::SourceExists(S"MySource")) {
            EventLog::CreateEventSource(S"MySource", S"MyNewLog");
        // Write an entry to the EventLog.
        myNewLog->WriteEntry(S"The Latest entry in the Event Log");
        int myEntries = myNewLog->Entries->Count;
        EventLogEntry* entry = myNewLog->Entries->Item[myEntries-1];
        EntryWrittenEventArgs* myEntryEventArgs = new EntryWrittenEventArgs();
        MyOnEntry(myNewLog, myEntryEventArgs);
    } catch (Exception* e) {
        Console::WriteLine(S"Exception Raised{0}", e->Message);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Diagnostics

Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

EntryWrittenEventArgs Members | System.Diagnostics Namespace | EntryWritten | EntryWrittenEventHandler | EventLog