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
- StreamAsIStream.cs
- MatrixCamera.cs
- SspiSafeHandles.cs
- HtmlWindowCollection.cs
- CommonObjectSecurity.cs
- TextFindEngine.cs
- CharAnimationUsingKeyFrames.cs
- DoubleCollectionValueSerializer.cs
- DispatcherHookEventArgs.cs
- Quad.cs
- SiteMapDataSource.cs
- ClientTarget.cs
- MetaType.cs
- AuthenticationModuleElement.cs
- WindowsEditBoxRange.cs
- safex509handles.cs
- Repeater.cs
- SystemUnicastIPAddressInformation.cs
- TiffBitmapDecoder.cs
- GenericUI.cs
- complextypematerializer.cs
- SqlConnectionHelper.cs
- HttpListenerContext.cs
- ScrollContentPresenter.cs
- wgx_commands.cs
- ResourceManagerWrapper.cs
- LOSFormatter.cs
- CheckBox.cs
- HideDisabledControlAdapter.cs
- TableLayoutStyleCollection.cs
- ConfigXmlSignificantWhitespace.cs
- PeerResolverBindingElement.cs
- DataGridViewHitTestInfo.cs
- XhtmlBasicValidationSummaryAdapter.cs
- JavaScriptSerializer.cs
- TypeSystemHelpers.cs
- DetailsViewInsertedEventArgs.cs
- SqlConnectionHelper.cs
- LOSFormatter.cs
- __FastResourceComparer.cs
- RequestCache.cs
- EpmTargetPathSegment.cs
- ExtensionSimplifierMarkupObject.cs
- BmpBitmapEncoder.cs
- Simplifier.cs
- _TimerThread.cs
- HostVisual.cs
- TargetException.cs
- MiniConstructorInfo.cs
- ConsumerConnectionPointCollection.cs
- DbProviderSpecificTypePropertyAttribute.cs
- FormViewUpdatedEventArgs.cs
- UpdateProgress.cs
- TrackingMemoryStreamFactory.cs
- ProviderSettingsCollection.cs
- DefaultValueConverter.cs
- InvalidDataException.cs
- ExitEventArgs.cs
- WorkflowQueue.cs
- PropertyPathConverter.cs
- Comparer.cs
- StateManagedCollection.cs
- XmlDataSourceView.cs
- DocumentXmlWriter.cs
- OracleDataReader.cs
- QilUnary.cs
- ConsoleTraceListener.cs
- UInt32.cs
- MetadataCacheItem.cs
- Image.cs
- CodeParameterDeclarationExpression.cs
- BrowserDefinition.cs
- ListBindingConverter.cs
- Menu.cs
- WebPartHeaderCloseVerb.cs
- GeometryHitTestParameters.cs
- DLinqAssociationProvider.cs
- SingleConverter.cs
- WebPartTracker.cs
- SQLConvert.cs
- Control.cs
- OptionUsage.cs
- EventRouteFactory.cs
- DBConcurrencyException.cs
- PeerTransportListenAddressConverter.cs
- SQLRoleProvider.cs
- ErrorWrapper.cs
- XmlText.cs
- WsatConfiguration.cs
- SqlCommandBuilder.cs
- XamlTemplateSerializer.cs
- IgnoreDeviceFilterElementCollection.cs
- DbParameterCollectionHelper.cs
- SemaphoreFullException.cs
- CardSpacePolicyElement.cs
- FontFamily.cs
- SHA1CryptoServiceProvider.cs
- Int64.cs
- BindableAttribute.cs
- DashStyle.cs