Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / SafeIUnknown.cs / 1305376 / SafeIUnknown.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.Tools.ServiceModel.WsatConfig { using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; using System.Security.Permissions; // Keep an interface pointer that will not be used in a SafeHandle derived so // that it will be properly released. internal sealed class SafeIUnknown : SafeHandle { // This constructor is called by ComInterop [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SafeIUnknown() : base(IntPtr.Zero, true) { } // This constructor is called by ComInterop [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SafeIUnknown(IntPtr unknown) : base(IntPtr.Zero, true) { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { base.handle = unknown; } } public override bool IsInvalid { get { return (IsClosed || (IntPtr.Zero == base.handle)); } } override protected bool ReleaseHandle() { // NOTE: The SafeHandle class guarantees this will be called exactly once. IntPtr ptr = base.handle; base.handle = IntPtr.Zero; if (IntPtr.Zero != ptr) { Marshal.Release(ptr); } return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.Tools.ServiceModel.WsatConfig { using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; using System.Security.Permissions; // Keep an interface pointer that will not be used in a SafeHandle derived so // that it will be properly released. internal sealed class SafeIUnknown : SafeHandle { // This constructor is called by ComInterop [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SafeIUnknown() : base(IntPtr.Zero, true) { } // This constructor is called by ComInterop [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SafeIUnknown(IntPtr unknown) : base(IntPtr.Zero, true) { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { base.handle = unknown; } } public override bool IsInvalid { get { return (IsClosed || (IntPtr.Zero == base.handle)); } } override protected bool ReleaseHandle() { // NOTE: The SafeHandle class guarantees this will be called exactly once. IntPtr ptr = base.handle; base.handle = IntPtr.Zero; if (IntPtr.Zero != ptr) { Marshal.Release(ptr); } return true; } } } // 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
- StyleCollectionEditor.cs
- ClientScriptManagerWrapper.cs
- CheckBoxList.cs
- RegexInterpreter.cs
- XmlComment.cs
- TypeNameParser.cs
- XmlObjectSerializerReadContext.cs
- ObjectSet.cs
- ForEachAction.cs
- VBIdentifierNameEditor.cs
- CmsInterop.cs
- SQLDateTimeStorage.cs
- FormViewUpdateEventArgs.cs
- InternalConfigEventArgs.cs
- SiteMapNodeItem.cs
- VersionedStreamOwner.cs
- PolyBezierSegmentFigureLogic.cs
- ProjectionCamera.cs
- AtomicFile.cs
- TaskFormBase.cs
- DataGridColumn.cs
- DetailsViewUpdateEventArgs.cs
- _NegoState.cs
- ListViewAutomationPeer.cs
- DataFieldConverter.cs
- SimpleBitVector32.cs
- ActivationProxy.cs
- OleDbRowUpdatedEvent.cs
- CodeIndexerExpression.cs
- SqlFacetAttribute.cs
- ValidatedControlConverter.cs
- TypographyProperties.cs
- Registry.cs
- KeyInterop.cs
- CollectionContainer.cs
- RadioButton.cs
- DSACryptoServiceProvider.cs
- SqlClientPermission.cs
- WorkflowPrinting.cs
- ObjectSecurity.cs
- _AutoWebProxyScriptWrapper.cs
- Update.cs
- CngAlgorithmGroup.cs
- OleDbPermission.cs
- HttpListenerResponse.cs
- HttpCachePolicyElement.cs
- XmlUtil.cs
- SendMessageContent.cs
- AnnotationDocumentPaginator.cs
- InternalBufferOverflowException.cs
- CheckBoxField.cs
- OracleCommandSet.cs
- DateTimeStorage.cs
- HttpResponseBase.cs
- DifferencingCollection.cs
- LocatorGroup.cs
- SqlConnectionString.cs
- Form.cs
- XPathQilFactory.cs
- JoinCqlBlock.cs
- RegistryHandle.cs
- ValueOfAction.cs
- ScriptServiceAttribute.cs
- ToolboxItemCollection.cs
- IListConverters.cs
- ToolStripOverflowButton.cs
- OleDbConnection.cs
- EncoderBestFitFallback.cs
- OdbcConnectionPoolProviderInfo.cs
- DrawingContextWalker.cs
- SelectorItemAutomationPeer.cs
- InheritanceContextChangedEventManager.cs
- HttpCookieCollection.cs
- WindowsGraphics2.cs
- AutomationProperties.cs
- FormClosingEvent.cs
- UndoManager.cs
- InputLanguageManager.cs
- RadioButtonRenderer.cs
- ConsumerConnectionPointCollection.cs
- DbModificationClause.cs
- Listbox.cs
- ToolStripMenuItem.cs
- QilVisitor.cs
- _PooledStream.cs
- WebDisplayNameAttribute.cs
- TextTrailingCharacterEllipsis.cs
- DesignerView.cs
- PointAnimationClockResource.cs
- FragmentQueryKB.cs
- QueryExpression.cs
- InternalConfigHost.cs
- CrossContextChannel.cs
- OleDbException.cs
- QuadraticBezierSegment.cs
- ToolStripGripRenderEventArgs.cs
- XmlSchemaSimpleContent.cs
- sqlstateclientmanager.cs
- TextInfo.cs
- XmlIlTypeHelper.cs