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
- SelectionPattern.cs
- SelectingProviderEventArgs.cs
- BooleanToVisibilityConverter.cs
- SiteMapNodeItem.cs
- ScriptManagerProxy.cs
- DataGridView.cs
- GeneralTransform2DTo3DTo2D.cs
- SafeProcessHandle.cs
- WpfXamlLoader.cs
- ButtonFieldBase.cs
- DataStreams.cs
- xmlfixedPageInfo.cs
- UrlAuthFailedErrorFormatter.cs
- JpegBitmapDecoder.cs
- LayoutInformation.cs
- CellRelation.cs
- StreamMarshaler.cs
- ScalarType.cs
- DynamicDocumentPaginator.cs
- NumberSubstitution.cs
- TopClause.cs
- WebPartsPersonalizationAuthorization.cs
- XmlLanguage.cs
- SqlBuffer.cs
- BitmapCache.cs
- ToolStripButton.cs
- WindowPatternIdentifiers.cs
- FlowDocumentPageViewerAutomationPeer.cs
- RootBrowserWindow.cs
- NamedPermissionSet.cs
- AnonymousIdentificationSection.cs
- DataGridColumnCollectionEditor.cs
- DNS.cs
- FileEnumerator.cs
- DataFormats.cs
- DocumentScope.cs
- EntityCommand.cs
- wgx_exports.cs
- TriggerCollection.cs
- SetterTriggerConditionValueConverter.cs
- DBNull.cs
- HandlerBase.cs
- FloatUtil.cs
- SiteMapDataSourceView.cs
- RuleValidation.cs
- TabControlToolboxItem.cs
- LambdaCompiler.Generated.cs
- EdmError.cs
- ObjectDataSourceMethodEditor.cs
- ViewCellRelation.cs
- XmlnsCache.cs
- SymmetricKeyWrap.cs
- RIPEMD160.cs
- DecoderReplacementFallback.cs
- WindowsTab.cs
- QualificationDataAttribute.cs
- filewebresponse.cs
- SecurityUtils.cs
- QilReplaceVisitor.cs
- ContentTextAutomationPeer.cs
- FixedElement.cs
- SchemaNotation.cs
- VectorCollection.cs
- SpeechSynthesizer.cs
- X509CertificateTokenFactoryCredential.cs
- NetCodeGroup.cs
- TextRange.cs
- LowerCaseStringConverter.cs
- IpcChannelHelper.cs
- WorkflowRuntimeServiceElement.cs
- BackgroundWorker.cs
- CombinedHttpChannel.cs
- ReferenceConverter.cs
- InputLangChangeEvent.cs
- CheckoutException.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- LinkUtilities.cs
- DATA_BLOB.cs
- VideoDrawing.cs
- FileLoadException.cs
- FontClient.cs
- UnsafeNativeMethods.cs
- DesignerTransactionCloseEvent.cs
- WsatEtwTraceListener.cs
- ScrollViewer.cs
- StorageRoot.cs
- SecurityRuntime.cs
- FontCacheLogic.cs
- RangeValidator.cs
- Duration.cs
- KeyBinding.cs
- LineProperties.cs
- UnauthorizedAccessException.cs
- NetPipeSection.cs
- UIElementParagraph.cs
- Cursors.cs
- UserControlCodeDomTreeGenerator.cs
- ResourceReferenceExpressionConverter.cs
- MapPathBasedVirtualPathProvider.cs
- JsonDeserializer.cs