Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Diagnostics / Eventing / Reader / EventLogHandle.cs / 1305376 / EventLogHandle.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: EventLogHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native EVT_HANDLE - obtained from EventLog Native Methods. ** ============================================================*/ using System; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Diagnostics.Eventing.Reader { // // Marked as SecurityCritical due to link demands from inherited // SafeHandle members. // // marked as Safe since the only real operation that is performed // by this class is NativeWrapper.EvtClose and that is protected // by a full Demand() before doing any work. [System.Security.SecuritySafeCritical] internal sealed class EventLogHandle : SafeHandle { // Called by P/Invoke when returning SafeHandles private EventLogHandle() : base(IntPtr.Zero, true) { } internal EventLogHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { SetHandle(handle); } public override bool IsInvalid { get { return IsClosed || handle == IntPtr.Zero; } } protected override bool ReleaseHandle() { NativeWrapper.EvtClose(handle); handle = IntPtr.Zero; return true; } // DONT compare EventLogHandle with EventLogHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed public static EventLogHandle Zero { get { return new EventLogHandle(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: EventLogHandle ** ** Purpose: ** This internal class is a SafeHandle implementation over a ** native EVT_HANDLE - obtained from EventLog Native Methods. ** ============================================================*/ using System; using System.Runtime.InteropServices; using System.Security.Permissions; namespace System.Diagnostics.Eventing.Reader { // // Marked as SecurityCritical due to link demands from inherited // SafeHandle members. // // marked as Safe since the only real operation that is performed // by this class is NativeWrapper.EvtClose and that is protected // by a full Demand() before doing any work. [System.Security.SecuritySafeCritical] internal sealed class EventLogHandle : SafeHandle { // Called by P/Invoke when returning SafeHandles private EventLogHandle() : base(IntPtr.Zero, true) { } internal EventLogHandle(IntPtr handle, bool ownsHandle) : base(IntPtr.Zero, ownsHandle) { SetHandle(handle); } public override bool IsInvalid { get { return IsClosed || handle == IntPtr.Zero; } } protected override bool ReleaseHandle() { NativeWrapper.EvtClose(handle); handle = IntPtr.Zero; return true; } // DONT compare EventLogHandle with EventLogHandle.Zero // use IsInvalid instead. Zero is provided where a NULL handle needed public static EventLogHandle Zero { get { return new EventLogHandle(); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TemplateParser.cs
- SystemIPInterfaceProperties.cs
- NestPullup.cs
- ReferenceService.cs
- ValidationError.cs
- HostProtectionException.cs
- FixedTextContainer.cs
- QueryCacheManager.cs
- CodeSubDirectory.cs
- UIElementCollection.cs
- XmlSchemaGroupRef.cs
- OneToOneMappingSerializer.cs
- X509CertificateChain.cs
- DataGridViewComboBoxEditingControl.cs
- CodeAttributeArgument.cs
- DocumentPaginator.cs
- ProtectedConfigurationProviderCollection.cs
- CaseInsensitiveComparer.cs
- AssemblyCollection.cs
- PreservationFileWriter.cs
- FuncCompletionCallbackWrapper.cs
- ThreadBehavior.cs
- TextInfo.cs
- SchemaManager.cs
- Int16KeyFrameCollection.cs
- WorkflowValidationFailedException.cs
- ProxyElement.cs
- DockProviderWrapper.cs
- Task.cs
- HMACRIPEMD160.cs
- DbReferenceCollection.cs
- InteropBitmapSource.cs
- ObjectDataSource.cs
- ArrayExtension.cs
- ValidationEventArgs.cs
- ToolStripContextMenu.cs
- RichTextBox.cs
- TemplateModeChangedEventArgs.cs
- BroadcastEventHelper.cs
- X509Certificate.cs
- SwitchAttribute.cs
- HttpException.cs
- CompiledIdentityConstraint.cs
- filewebrequest.cs
- SiteMapDataSourceView.cs
- InvalidCommandTreeException.cs
- MonthChangedEventArgs.cs
- DiscoveryInnerClientAdhoc11.cs
- SqlDelegatedTransaction.cs
- CommonDialog.cs
- InfiniteTimeSpanConverter.cs
- VectorKeyFrameCollection.cs
- ImageField.cs
- CompareValidator.cs
- XPathAncestorQuery.cs
- ConsoleKeyInfo.cs
- SelectorAutomationPeer.cs
- Freezable.cs
- ChannelServices.cs
- XmlSiteMapProvider.cs
- Tablet.cs
- HighContrastHelper.cs
- SharedPersonalizationStateInfo.cs
- PlanCompiler.cs
- DesignerObject.cs
- ResumeStoryboard.cs
- SqlExpander.cs
- HttpServerUtilityBase.cs
- MimeReflector.cs
- Quad.cs
- MenuItemStyleCollection.cs
- Point3DConverter.cs
- GlobalEventManager.cs
- ButtonAutomationPeer.cs
- TextEditorThreadLocalStore.cs
- DiagnosticTraceSource.cs
- APCustomTypeDescriptor.cs
- StorageAssociationSetMapping.cs
- BmpBitmapDecoder.cs
- StoreAnnotationsMap.cs
- AmbientLight.cs
- SpellerStatusTable.cs
- BulletChrome.cs
- RC2.cs
- ByteFacetDescriptionElement.cs
- ConcurrentBag.cs
- BlurBitmapEffect.cs
- SplitContainer.cs
- StrokeCollectionDefaultValueFactory.cs
- MobileUITypeEditor.cs
- VolatileResourceManager.cs
- FixedDocumentSequencePaginator.cs
- Composition.cs
- Nullable.cs
- SqlNode.cs
- DbConnectionPoolOptions.cs
- BitmapEffectDrawingContextWalker.cs
- Durable.cs
- Stack.cs
- CommandDevice.cs