private void HandleEventsRequestCompletion() { if (this.asyncException != null) { EventRecordWrittenEventArgs eventArgs = new EventRecordWrittenEventArgs(this.asyncException); this.IssueCallback(eventArgs); } for (int i = 0; i < this.numEventsInBuffer; i++) { if (!this.isSubscribing) { return; } EventLogRecord record = new EventLogRecord(new EventLogHandle(this.eventsBuffer[i], true), this.eventQuery.Session, this.cachedMetadataInformation); EventRecordWrittenEventArgs args2 = new EventRecordWrittenEventArgs(record); this.eventsBuffer[i] = IntPtr.Zero; this.IssueCallback(args2); } }
private void HandleEventsRequestCompletion() { if (this.asyncException != null) { EventRecordWrittenEventArgs args = new EventRecordWrittenEventArgs(this.asyncException.Data["RealException"] as Exception); IssueCallback(args); } for (int i = 0; i < this.numEventsInBuffer; i++) { if (!this.isSubscribing) { break; } EventLogRecord record = new EventLogRecord(new EventLogHandle(this.eventsBuffer[i], true), this.eventQuery.Session, this.cachedMetadataInformation); EventRecordWrittenEventArgs args = new EventRecordWrittenEventArgs(record); this.eventsBuffer[i] = IntPtr.Zero; // user is responsible for calling Dispose(). IssueCallback(args); } }
public EventRecord ReadEvent(TimeSpan timeout) { EventLogPermissionHolder.GetEventLogPermission().Demand(); if (this.isEof) { throw new InvalidOperationException(); } if (this.currentIndex >= this.eventCount) { this.GetNextBatch(timeout); if (this.currentIndex >= this.eventCount) { this.isEof = true; return(null); } } EventLogRecord record = new EventLogRecord(new EventLogHandle(this.eventsBuffer[this.currentIndex], true), this.eventQuery.Session, this.cachedMetadataInformation); this.currentIndex++; return(record); }
public EventRecord ReadEvent(TimeSpan timeout) { if (_isEof) throw new InvalidOperationException(); if (_currentIndex >= _eventCount) { // buffer is empty, get next batch. GetNextBatch(timeout); if (_currentIndex >= _eventCount) { _isEof = true; return null; } } EventLogRecord eventInstance = new EventLogRecord(new EventLogHandle(_eventsBuffer[_currentIndex], true), _eventQuery.Session, _cachedMetadataInformation); _currentIndex++; return eventInstance; }
internal void StartSubscribing() { if (this.isSubscribing) { throw new InvalidOperationException(); } int flags = 0; if (this.bookmark != null) { flags |= 3; } else if (this.readExistingEvents) { flags |= 2; } else { flags |= 1; } if (this.eventQuery.TolerateQueryErrors) { flags |= 0x1000; } EventLogPermissionHolder.GetEventLogPermission().Demand(); this.callbackThreadId = -1; this.unregisterDoneHandle = new AutoResetEvent(false); this.subscriptionWaitHandle = new AutoResetEvent(false); EventLogHandle bookmarkHandleFromBookmark = EventLogRecord.GetBookmarkHandleFromBookmark(this.bookmark); using (bookmarkHandleFromBookmark) { this.handle = NativeWrapper.EvtSubscribe(this.eventQuery.Session.Handle, this.subscriptionWaitHandle.SafeWaitHandle, this.eventQuery.Path, this.eventQuery.Query, bookmarkHandleFromBookmark, IntPtr.Zero, IntPtr.Zero, flags); } this.isSubscribing = true; this.RequestEvents(); this.registeredWaitHandle = ThreadPool.RegisterWaitForSingleObject(this.subscriptionWaitHandle, new WaitOrTimerCallback(this.SubscribedEventsAvailableCallback), null, -1, false); }
private void HandleEventsRequestCompletion() { if (this.asyncException != null) { EventRecordWrittenEventArgs args = new EventRecordWrittenEventArgs(this.asyncException.Data["RealException"] as Exception); IssueCallback(args); } for (int i = 0; i < this. numEventsInBuffer; i++) { if (!this.isSubscribing) break; EventLogRecord record = new EventLogRecord(new EventLogHandle(this.eventsBuffer[i], true), this.eventQuery.Session, this.cachedMetadataInformation); EventRecordWrittenEventArgs args = new EventRecordWrittenEventArgs(record); this.eventsBuffer[i] = IntPtr.Zero; // user is responsible for calling Dispose(). IssueCallback(args); } }
public EventLogReader(EventLogQuery eventQuery, EventBookmark bookmark) { if (eventQuery == null) { throw new ArgumentNullException("eventQuery"); } string logfile = null; if (eventQuery.ThePathType == PathType.FilePath) { logfile = eventQuery.Path; } _cachedMetadataInformation = new ProviderMetadataCachedInformation(eventQuery.Session, logfile, 50); //explicit data _eventQuery = eventQuery; //implicit _batchSize = 64; _eventsBuffer = new IntPtr[_batchSize]; // // compute the flag. // int flag = 0; if (_eventQuery.ThePathType == PathType.LogName) { flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryChannelPath; } else { flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryFilePath; } if (_eventQuery.ReverseDirection) { flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryReverseDirection; } if (_eventQuery.TolerateQueryErrors) { flag |= (int)UnsafeNativeMethods.EvtQueryFlags.EvtQueryTolerateQueryErrors; } _handle = NativeWrapper.EvtQuery(_eventQuery.Session.Handle, _eventQuery.Path, _eventQuery.Query, flag); EventLogHandle bookmarkHandle = EventLogRecord.GetBookmarkHandleFromBookmark(bookmark); if (!bookmarkHandle.IsInvalid) { using (bookmarkHandle) { NativeWrapper.EvtSeek(_handle, 1, bookmarkHandle, 0, UnsafeNativeMethods.EvtSeekFlags.EvtSeekRelativeToBookmark); } } }
internal EventRecordWrittenEventArgs(EventLogRecord record) { this.record = record; }
internal EventRecordWrittenEventArgs(EventLogRecord record) { this.record = record; }
public EventRecord ReadEvent(TimeSpan timeout) { EventLogPermissionHolder.GetEventLogPermission().Demand(); if (this.isEof) { throw new InvalidOperationException(); } if (this.currentIndex >= this.eventCount) { this.GetNextBatch(timeout); if (this.currentIndex >= this.eventCount) { this.isEof = true; return null; } } EventLogRecord record = new EventLogRecord(new EventLogHandle(this.eventsBuffer[this.currentIndex], true), this.eventQuery.Session, this.cachedMetadataInformation); this.currentIndex++; return record; }
private void HandleEventsRequestCompletion() { if (this.asyncException != null) { EventRecordWrittenEventArgs eventArgs = new EventRecordWrittenEventArgs(this.asyncException); this.IssueCallback(eventArgs); } for (int i = 0; i < this.numEventsInBuffer; i++) { if (!this.isSubscribing) { return; } EventLogRecord record = new EventLogRecord(new EventLogHandle(this.eventsBuffer[i], true), this.eventQuery.Session, this.cachedMetadataInformation); EventRecordWrittenEventArgs args2 = new EventRecordWrittenEventArgs(record); this.eventsBuffer[i] = IntPtr.Zero; this.IssueCallback(args2); } }
public EventRecord ReadEvent(TimeSpan timeout) { if (_isEof) throw new InvalidOperationException(); if (_currentIndex >= _eventCount) { // buffer is empty, get next batch. GetNextBatch(timeout); if (_currentIndex >= _eventCount) { _isEof = true; return null; } } EventLogRecord eventInstance = new EventLogRecord(new EventLogHandle(_eventsBuffer[_currentIndex], true), _eventQuery.Session, _cachedMetadataInformation); _currentIndex++; return eventInstance; }