Ejemplo n.º 1
0
 /// <devdoc>
 /// </devdoc>
 /// <internalonly/>
 private EventLogEntry(SerializationInfo info, StreamingContext context) {
     dataBuf = (byte[])info.GetValue("DataBuffer", typeof(byte[]));
     string logName = info.GetString("LogName");
     string machineName = info.GetString("MachineName");
     owner = new EventLogInternal(logName, machineName, "");
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 2
0
        // make sure only others in this package can create us
        internal EventLogEntry(byte[] buf, int offset, EventLogInternal log) {
            this.dataBuf = buf;
            this.bufOffset = offset;
            this.owner = log;

            GC.SuppressFinalize(this);
        }
 internal EventLogEntryCollection(EventLogInternal log) {
     this.log = log;
 }
        private static void AddListenerComponent(EventLogInternal component, string compMachineName, string compLogName) {
            lock (InternalSyncObject) {
                Debug.WriteLineIf(CompModSwitches.EventLog.TraceVerbose, "EventLog::AddListenerComponent(" + compLogName + ")");

                LogListeningInfo info = (LogListeningInfo) listenerInfos[compLogName];
                if (info != null) {
                    Debug.WriteLineIf(CompModSwitches.EventLog.TraceVerbose, "EventLog::AddListenerComponent: listener already active.");
                    info.listeningComponents.Add(component);
                    return;
                }

                info = new LogListeningInfo();
                info.listeningComponents.Add(component);

                info.handleOwner = new EventLogInternal(compLogName, compMachineName);

                // tell the event log system about it
                info.waitHandle = new AutoResetEvent(false); 
                bool success = UnsafeNativeMethods.NotifyChangeEventLog(info.handleOwner.ReadHandle, info.waitHandle.SafeWaitHandle);
                if (!success)
                    throw new InvalidOperationException(SR.GetString(SR.CantMonitorEventLog), SharedUtils.CreateSafeWin32Exception());

                info.registeredWaitHandle = ThreadPool.RegisterWaitForSingleObject(info.waitHandle, new WaitOrTimerCallback(StaticCompletionCallback), info, -1, false);

                listenerInfos[compLogName] = info;
            }
        }
        private static void RemoveListenerComponent(EventLogInternal component, string compLogName) {
            lock (InternalSyncObject) {
                Debug.WriteLineIf(CompModSwitches.EventLog.TraceVerbose, "EventLog::RemoveListenerComponent(" + compLogName + ")");

                LogListeningInfo info = (LogListeningInfo) listenerInfos[compLogName];
                Debug.Assert(info != null);

                // remove the requested component from the list.
                info.listeningComponents.Remove(component);
                if (info.listeningComponents.Count != 0)
                    return;

                // if that was the last interested compononent, destroy the handles and stop listening.

                info.handleOwner.Dispose();

                //Unregister the thread pool wait handle
                info.registeredWaitHandle.Unregister(info.waitHandle);
                // close the handle
                info.waitHandle.Close();

                listenerInfos[compLogName] = null;
            }
        }
Ejemplo n.º 6
0
 public static void WriteEvent(string source, EventInstance instance, byte[] data, params Object[] values) {
     using (EventLogInternal log = new EventLogInternal("", ".", CheckAndNormalizeSourceName(source))) {
         log.WriteEvent(instance, data, values);
     }
 }
Ejemplo n.º 7
0
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public static void WriteEntry(string source, string message, EventLogEntryType type, int eventID, short category,
                        byte[] rawData) {
     using (EventLogInternal log = new EventLogInternal("", ".", CheckAndNormalizeSourceName(source))) {
         log.WriteEntry(message, type, eventID, category, rawData);
     }
 }
Ejemplo n.º 8
0
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public EventLog(string logName, string machineName, string source) {
     m_underlyingEventLog = new EventLogInternal(logName, machineName, source, this);
 }
 public static void WriteEvent(string source, EventInstance instance, params object[] values)
 {
     using (EventLogInternal internal2 = new EventLogInternal("", ".", CheckAndNormalizeSourceName(source)))
     {
         internal2.WriteEvent(instance, null, values);
     }
 }
 private static void RemoveListenerComponent(EventLogInternal component, string compLogName)
 {
     lock (InternalSyncObject)
     {
         LogListeningInfo info = (LogListeningInfo) listenerInfos[compLogName];
         info.listeningComponents.Remove(component);
         if (info.listeningComponents.Count == 0)
         {
             info.handleOwner.Dispose();
             info.registeredWaitHandle.Unregister(info.waitHandle);
             info.waitHandle.Close();
             listenerInfos[compLogName] = null;
         }
     }
 }
 private static void AddListenerComponent(EventLogInternal component, string compMachineName, string compLogName)
 {
     lock (InternalSyncObject)
     {
         LogListeningInfo state = (LogListeningInfo) listenerInfos[compLogName];
         if (state != null)
         {
             state.listeningComponents.Add(component);
         }
         else
         {
             state = new LogListeningInfo();
             state.listeningComponents.Add(component);
             state.handleOwner = new EventLogInternal(compLogName, compMachineName);
             state.waitHandle = new AutoResetEvent(false);
             if (!Microsoft.Win32.UnsafeNativeMethods.NotifyChangeEventLog(state.handleOwner.ReadHandle, state.waitHandle.SafeWaitHandle))
             {
                 throw new InvalidOperationException(SR.GetString("CantMonitorEventLog"), SharedUtils.CreateSafeWin32Exception());
             }
             state.registeredWaitHandle = ThreadPool.RegisterWaitForSingleObject(state.waitHandle, new WaitOrTimerCallback(EventLogInternal.StaticCompletionCallback), state, -1, false);
             listenerInfos[compLogName] = state;
         }
     }
 }