protected virtual void Dispose(bool disposing) { if (_renderContextHandleValues != null && !_renderContextHandleValues.IsInvalid) { _renderContextHandleValues.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (this == s_globalSession) { throw new InvalidOperationException(); } } if (this.renderContextHandleSystem != null && !this.renderContextHandleSystem.IsInvalid) { this.renderContextHandleSystem.Dispose(); } if (this.renderContextHandleUser != null && !this.renderContextHandleUser.IsInvalid) { this.renderContextHandleUser.Dispose(); } if (Handle != null && !Handle.IsInvalid) { Handle.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (_handle != null && !_handle.IsInvalid) { _handle.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (this == globalSession) { throw new InvalidOperationException(); } EventLogPermissionHolder.GetEventLogPermission().Demand(); } if (this.renderContextHandleSystem != null && !this.renderContextHandleSystem.IsInvalid) { this.renderContextHandleSystem.Dispose(); } if (this.renderContextHandleUser != null && !this.renderContextHandleUser.IsInvalid) { this.renderContextHandleUser.Dispose(); } if (handle != null && !handle.IsInvalid) { handle.Dispose(); } }
internal void StopSubscribing() { EventLogPermissionHolder.GetEventLogPermission().Demand(); // // need to set isSubscribing to false before waiting for completion of callback. // this.isSubscribing = false; if (this.registeredWaitHandle != null) { this.registeredWaitHandle.Unregister(this.unregisterDoneHandle); if (this.callbackThreadId != Thread.CurrentThread.ManagedThreadId) { // // not calling Stop from within callback - wait for // any outstanding callbacks to complete. // if (this.unregisterDoneHandle != null) { this.unregisterDoneHandle.WaitOne(); } } this.registeredWaitHandle = null; } if (this.unregisterDoneHandle != null) { this.unregisterDoneHandle.Close(); this.unregisterDoneHandle = null; } if (this.subscriptionWaitHandle != null) { this.subscriptionWaitHandle.Close(); this.subscriptionWaitHandle = null; } for (int i = 0; i < this.numEventsInBuffer; i++) { if (eventsBuffer[i] != IntPtr.Zero) { NativeWrapper.EvtClose(eventsBuffer[i]); eventsBuffer[i] = IntPtr.Zero; } } this.numEventsInBuffer = 0; if (handle != null && !handle.IsInvalid) { handle.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { EventLogPermissionHolder.GetEventLogPermission().Demand(); } if (handle != null && !handle.IsInvalid) { handle.Dispose(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { EventLogPermissionHolder.GetEventLogPermission().Demand(); } if (renderContextHandleValues != null && !renderContextHandleValues.IsInvalid) { renderContextHandleValues.Dispose(); } }
protected virtual void Dispose(bool disposing) { while (_currentIndex < _eventCount) { NativeWrapper.EvtClose(_eventsBuffer[_currentIndex]); _currentIndex++; } if (_handle != null && !_handle.IsInvalid) _handle.Dispose(); }
internal void StopSubscribing() { // C:\public\System.Diagnostics.Eventing\Microsoft\Win32\SafeHandles; // Need to set isSubscribing to false before waiting for completion of callback. _isSubscribing = false; if (_registeredWaitHandle != null) { _registeredWaitHandle.Unregister(_unregisterDoneHandle); if (_callbackThreadId != Environment.CurrentManagedThreadId) { // Not calling Stop from within callback - wait for // Any outstanding callbacks to complete. if (_unregisterDoneHandle != null) { _unregisterDoneHandle.WaitOne(); } } _registeredWaitHandle = null; } if (_unregisterDoneHandle != null) { _unregisterDoneHandle.Close(); _unregisterDoneHandle = null; } if (_subscriptionWaitHandle != null) { _subscriptionWaitHandle.Close(); _subscriptionWaitHandle = null; } for (int i = 0; i < _numEventsInBuffer; i++) { if (_eventsBuffer[i] != IntPtr.Zero) { UnsafeNativeMethods.EvtClose(_eventsBuffer[i]); _eventsBuffer[i] = IntPtr.Zero; } } _numEventsInBuffer = 0; if (_handle != null && !_handle.IsInvalid) { _handle.Dispose(); } }
protected override void Dispose(bool disposing) { try { if (_handle != null && !_handle.IsInvalid) { _handle.Dispose(); } } finally { base.Dispose(disposing); } }
protected virtual void Dispose(bool disposing) { if (disposing) { EventLogPermissionHolder.GetEventLogPermission().Demand(); } while (this.currentIndex < this.eventCount) { NativeWrapper.EvtClose(eventsBuffer[this.currentIndex]); this.currentIndex++; } if (handle != null && !handle.IsInvalid) { handle.Dispose(); } }
internal object GetProviderListProperty(EventLogHandle providerHandle, UnsafeNativeMethods.EvtPublisherMetadataPropertyId metadataProperty) { EventLogHandle elHandle = EventLogHandle.Zero; try { UnsafeNativeMethods.EvtPublisherMetadataPropertyId propName; UnsafeNativeMethods.EvtPublisherMetadataPropertyId propValue; UnsafeNativeMethods.EvtPublisherMetadataPropertyId propMessageId; ObjectTypeName objectTypeName; List <EventLevel> levelList = null; List <EventOpcode> opcodeList = null; List <EventKeyword> keywordList = null; List <EventTask> taskList = null; elHandle = NativeWrapper.EvtGetPublisherMetadataPropertyHandle(providerHandle, metadataProperty); int arraySize = NativeWrapper.EvtGetObjectArraySize(elHandle); switch (metadataProperty) { case UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevels: propName = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevelName; propValue = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevelValue; propMessageId = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataLevelMessageID; objectTypeName = ObjectTypeName.Level; levelList = new List <EventLevel>(arraySize); break; case UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodes: propName = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodeName; propValue = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodeValue; propMessageId = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataOpcodeMessageID; objectTypeName = ObjectTypeName.Opcode; opcodeList = new List <EventOpcode>(arraySize); break; case UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywords: propName = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywordName; propValue = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywordValue; propMessageId = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataKeywordMessageID; objectTypeName = ObjectTypeName.Keyword; keywordList = new List <EventKeyword>(arraySize); break; case UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTasks: propName = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTaskName; propValue = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTaskValue; propMessageId = UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTaskMessageID; objectTypeName = ObjectTypeName.Task; taskList = new List <EventTask>(arraySize); break; default: return(null); } for (int index = 0; index < arraySize; index++) { string generalName = (string)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)propName); uint generalValue = 0; long generalValueKeyword = 0; if (objectTypeName != ObjectTypeName.Keyword) { generalValue = (uint)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)propValue); } else { generalValueKeyword = unchecked ((long)((ulong)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)propValue))); } int generalMessageId = unchecked ((int)((uint)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)propMessageId))); string generalDisplayName = null; if (generalMessageId == -1) { if (providerHandle != _defaultProviderHandle) { if (_defaultProviderHandle.IsInvalid) { _defaultProviderHandle = NativeWrapper.EvtOpenProviderMetadata(_session.Handle, null, null, 0, 0); } switch (objectTypeName) { case ObjectTypeName.Level: generalDisplayName = FindStandardLevelDisplayName(generalName, generalValue); break; case ObjectTypeName.Opcode: generalDisplayName = FindStandardOpcodeDisplayName(generalName, generalValue >> 16); break; case ObjectTypeName.Keyword: generalDisplayName = FindStandardKeywordDisplayName(generalName, generalValueKeyword); break; case ObjectTypeName.Task: generalDisplayName = FindStandardTaskDisplayName(generalName, generalValue); break; default: generalDisplayName = null; break; } } } else { generalDisplayName = NativeWrapper.EvtFormatMessage(providerHandle, unchecked ((uint)generalMessageId)); } switch (objectTypeName) { case ObjectTypeName.Level: levelList.Add(new EventLevel(generalName, (int)generalValue, generalDisplayName)); break; case ObjectTypeName.Opcode: opcodeList.Add(new EventOpcode(generalName, (int)(generalValue >> 16), generalDisplayName)); break; case ObjectTypeName.Keyword: keywordList.Add(new EventKeyword(generalName, (long)generalValueKeyword, generalDisplayName)); break; case ObjectTypeName.Task: Guid taskGuid = (Guid)NativeWrapper.EvtGetObjectArrayProperty(elHandle, index, (int)UnsafeNativeMethods.EvtPublisherMetadataPropertyId.EvtPublisherMetadataTaskEventGuid); taskList.Add(new EventTask(generalName, (int)generalValue, generalDisplayName, taskGuid)); break; default: return(null); } } switch (objectTypeName) { case ObjectTypeName.Level: return(levelList); case ObjectTypeName.Opcode: return(opcodeList); case ObjectTypeName.Keyword: return(keywordList); case ObjectTypeName.Task: return(taskList); } return(null); } finally { elHandle.Dispose(); } }