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
- QueryParameter.cs
- EncoderReplacementFallback.cs
- Ray3DHitTestResult.cs
- XmlNamespaceMappingCollection.cs
- XmlILStorageConverter.cs
- RegexCode.cs
- TypeElement.cs
- CheckBoxList.cs
- IpcChannelHelper.cs
- ScanQueryOperator.cs
- StaticDataManager.cs
- PolicyUtility.cs
- SchemaDeclBase.cs
- SchemaTableColumn.cs
- ScrollItemProviderWrapper.cs
- ScaleTransform3D.cs
- WpfWebRequestHelper.cs
- PieceNameHelper.cs
- SqlDataSourceRefreshSchemaForm.cs
- IsolatedStorageFile.cs
- UpDownBaseDesigner.cs
- DbParameterHelper.cs
- EnumerableCollectionView.cs
- EncodingInfo.cs
- SizeKeyFrameCollection.cs
- Internal.cs
- X509Certificate2Collection.cs
- ApplicationInfo.cs
- ActiveDocumentEvent.cs
- BasicHttpBindingElement.cs
- StatusBarAutomationPeer.cs
- FastEncoderStatics.cs
- BStrWrapper.cs
- PageFunction.cs
- CodeStatementCollection.cs
- CapabilitiesUse.cs
- FrameDimension.cs
- TextParagraphCache.cs
- FileDialogCustomPlacesCollection.cs
- PropertyKey.cs
- StylusTip.cs
- TextEditorContextMenu.cs
- CodeIterationStatement.cs
- CqlParser.cs
- RemotingAttributes.cs
- COM2ComponentEditor.cs
- TryExpression.cs
- ShaderRenderModeValidation.cs
- ByteStorage.cs
- WMIInterop.cs
- PerformanceCounterNameAttribute.cs
- BuildProvidersCompiler.cs
- TranslateTransform.cs
- SimpleApplicationHost.cs
- ResourceDictionary.cs
- DragStartedEventArgs.cs
- OptimalTextSource.cs
- Translator.cs
- SqlFunctionAttribute.cs
- PolicyLevel.cs
- RequestCachingSection.cs
- SelectionPatternIdentifiers.cs
- DrawingAttributeSerializer.cs
- Helper.cs
- ConfigurationPropertyCollection.cs
- Help.cs
- HttpHeaderCollection.cs
- CharacterMetrics.cs
- QilTernary.cs
- CommonDialog.cs
- SafeFreeMibTable.cs
- ConfigXmlWhitespace.cs
- OciEnlistContext.cs
- ProgressiveCrcCalculatingStream.cs
- TextChange.cs
- AutoSizeComboBox.cs
- UniqueTransportManagerRegistration.cs
- securestring.cs
- EntityCommandCompilationException.cs
- BasicExpandProvider.cs
- Selection.cs
- ServiceDesigner.cs
- Int32AnimationBase.cs
- PathGradientBrush.cs
- ContextMenu.cs
- PageAsyncTaskManager.cs
- AspCompat.cs
- LZCodec.cs
- SimplePropertyEntry.cs
- SecurityStateEncoder.cs
- CounterNameConverter.cs
- TagMapInfo.cs
- ConfigurationSection.cs
- TextParagraphView.cs
- ToolStripGripRenderEventArgs.cs
- PasswordRecoveryDesigner.cs
- TerminateWorkflow.cs
- WebPartEditorApplyVerb.cs
- BamlRecords.cs
- TargetConverter.cs