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
- PopupEventArgs.cs
- HtmlButton.cs
- NativeMethods.cs
- AlternateView.cs
- DataGridViewDataErrorEventArgs.cs
- CompilerTypeWithParams.cs
- AlphabeticalEnumConverter.cs
- Keywords.cs
- CategoryNameCollection.cs
- LicenseContext.cs
- TemplateControl.cs
- CompilerTypeWithParams.cs
- DataGridColumnCollection.cs
- ReturnType.cs
- RelationshipManager.cs
- AsmxEndpointPickerExtension.cs
- QilInvoke.cs
- LayoutEvent.cs
- LabelEditEvent.cs
- ComplexTypeEmitter.cs
- ReceiveActivityDesigner.cs
- LocalizationParserHooks.cs
- LineMetrics.cs
- BoundConstants.cs
- PermissionAttributes.cs
- CompilerCollection.cs
- LookupNode.cs
- IApplicationTrustManager.cs
- XXXInfos.cs
- VectorCollectionConverter.cs
- GeneralTransform3DTo2DTo3D.cs
- LongValidatorAttribute.cs
- FunctionCommandText.cs
- IgnoreDataMemberAttribute.cs
- ToolStripProgressBar.cs
- ProviderException.cs
- TableItemPattern.cs
- MetadataUtilsSmi.cs
- GenerateTemporaryTargetAssembly.cs
- PrintDialog.cs
- AttributeEmitter.cs
- panel.cs
- RequestCache.cs
- CookieHandler.cs
- FileDetails.cs
- TextTreeText.cs
- base64Transforms.cs
- ObjectDataSourceView.cs
- SharedConnectionInfo.cs
- CalendarDay.cs
- Monitor.cs
- DocumentApplicationJournalEntry.cs
- MouseEventArgs.cs
- autovalidator.cs
- RootCodeDomSerializer.cs
- DrawingCollection.cs
- ContractMapping.cs
- XsdDuration.cs
- LogLogRecordEnumerator.cs
- OutputCacheSection.cs
- MachineKey.cs
- PrintingPermission.cs
- DataGridCell.cs
- StringComparer.cs
- XhtmlTextWriter.cs
- InternalConfigEventArgs.cs
- MobileTemplatedControlDesigner.cs
- _KerberosClient.cs
- FlowNode.cs
- Blend.cs
- ObjectIDGenerator.cs
- ApplicationActivator.cs
- StorageConditionPropertyMapping.cs
- CroppedBitmap.cs
- ValidationResult.cs
- TcpConnectionPool.cs
- MethodAccessException.cs
- ZipPackagePart.cs
- DrawTreeNodeEventArgs.cs
- Inline.cs
- SmtpNtlmAuthenticationModule.cs
- SqlClientWrapperSmiStream.cs
- Verify.cs
- _LocalDataStoreMgr.cs
- XmlKeywords.cs
- DataControlFieldsEditor.cs
- PrintDialogException.cs
- SchemaCollectionCompiler.cs
- HtmlHistory.cs
- DecoderFallback.cs
- TimeSpanMinutesConverter.cs
- BinaryMethodMessage.cs
- XD.cs
- RenderOptions.cs
- ThreadStateException.cs
- _HeaderInfo.cs
- TargetParameterCountException.cs
- QilExpression.cs
- OleDbConnectionInternal.cs
- FactoryGenerator.cs