Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SecurityContext.cs
- EntityReference.cs
- MailAddressParser.cs
- InstanceHandleReference.cs
- WebPartAuthorizationEventArgs.cs
- QilPatternVisitor.cs
- TextBreakpoint.cs
- PingReply.cs
- ActiveXHost.cs
- httpapplicationstate.cs
- EntityProviderServices.cs
- SQLSingle.cs
- SecurityUtils.cs
- HttpCachePolicy.cs
- WindowsListViewItemCheckBox.cs
- PipeStream.cs
- PostBackOptions.cs
- BinaryUtilClasses.cs
- BinaryWriter.cs
- IisTraceListener.cs
- HttpRequest.cs
- RootProfilePropertySettingsCollection.cs
- IMembershipProvider.cs
- SqlDataSourceCache.cs
- LOSFormatter.cs
- SqlUnionizer.cs
- ObjectAssociationEndMapping.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- SiteIdentityPermission.cs
- ConditionCollection.cs
- MetadataArtifactLoaderResource.cs
- FrameDimension.cs
- PrimarySelectionGlyph.cs
- InvalidAsynchronousStateException.cs
- WebBrowserProgressChangedEventHandler.cs
- TrackingProfileSerializer.cs
- TransportChannelFactory.cs
- BuildResultCache.cs
- DiffuseMaterial.cs
- WebContext.cs
- ResourcesChangeInfo.cs
- TreeView.cs
- SpellerInterop.cs
- MultilineStringEditor.cs
- Converter.cs
- UserPreferenceChangingEventArgs.cs
- AudioFormatConverter.cs
- FieldBuilder.cs
- ScriptModule.cs
- RuleSetBrowserDialog.cs
- ConnectionPointGlyph.cs
- SiteMapProvider.cs
- ClientReliableChannelBinder.cs
- DataListItem.cs
- Fx.cs
- WebMessageEncodingBindingElement.cs
- XamlToRtfWriter.cs
- AndCondition.cs
- EditableLabelControl.cs
- Byte.cs
- CqlLexer.cs
- PartitionedStreamMerger.cs
- _ConnectionGroup.cs
- GridSplitter.cs
- DeviceFilterDictionary.cs
- ManagedWndProcTracker.cs
- RequestCachePolicyConverter.cs
- JoinElimination.cs
- AsnEncodedData.cs
- HttpCachePolicyBase.cs
- WorkflowPrinting.cs
- SmuggledIUnknown.cs
- UpDownEvent.cs
- MailHeaderInfo.cs
- PageCatalogPartDesigner.cs
- State.cs
- Label.cs
- KeyedPriorityQueue.cs
- SqlConnectionStringBuilder.cs
- System.Data_BID.cs
- TableLayoutPanelResizeGlyph.cs
- NameValueCollection.cs
- OracleBoolean.cs
- GeneralTransform2DTo3DTo2D.cs
- Merger.cs
- ResourceAttributes.cs
- DirectoryInfo.cs
- DataGridAddNewRow.cs
- StringCollection.cs
- ResponseStream.cs
- ButtonChrome.cs
- TogglePattern.cs
- SQlBooleanStorage.cs
- Line.cs
- UpDownEvent.cs
- EventLogEntryCollection.cs
- ArraySet.cs
- Rect3D.cs
- ViewBase.cs
- ResourceReferenceExpression.cs