Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / PtsHost / UnmanagedHandle.cs / 1305600 / UnmanagedHandle.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: UnmanagedHandle.cs
//
// Description: Definition for Unmanaged Handle. Provides identity (handle),
// which can be used in unmanaged world.
//
// History:
// 05/02/2003 : [....] - moving from Avalon branch.
//
//---------------------------------------------------------------------------
using System;
namespace MS.Internal.PtsHost
{
///
/// Provides identity (handle), which can be used in unmanaged world.
/// If object is passed into unmanaged world, and there is a need to identify
/// that object later on, its class should inherit from UnmanagedHandle.
///
internal class UnmanagedHandle : IDisposable
{
///
/// Constructor. Used when object derives from UnmanagedHandle.
///
///
/// PTS context
///
protected UnmanagedHandle(PtsContext ptsContext)
{
_ptsContext = ptsContext;
_handle = ptsContext.CreateHandle(this);
}
///
/// Dispose the object and release handle.
///
public virtual void Dispose()
{
try
{
_ptsContext.ReleaseHandle(_handle);
}
finally
{
_handle = IntPtr.Zero;
}
GC.SuppressFinalize(this);
}
///
/// Handle of an object.
///
internal IntPtr Handle
{
get
{
return _handle;
}
}
private IntPtr _handle;
///
/// PtsContext that is the owner of the handle.
/// It is required to store it here for Dispose. When Dispose is called
/// it is not always possible to get instance of PtsContext that
/// has been used to create this handle.
///
internal PtsContext PtsContext { get { return _ptsContext; } }
private readonly PtsContext _ptsContext;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// File: UnmanagedHandle.cs
//
// Description: Definition for Unmanaged Handle. Provides identity (handle),
// which can be used in unmanaged world.
//
// History:
// 05/02/2003 : [....] - moving from Avalon branch.
//
//---------------------------------------------------------------------------
using System;
namespace MS.Internal.PtsHost
{
///
/// Provides identity (handle), which can be used in unmanaged world.
/// If object is passed into unmanaged world, and there is a need to identify
/// that object later on, its class should inherit from UnmanagedHandle.
///
internal class UnmanagedHandle : IDisposable
{
///
/// Constructor. Used when object derives from UnmanagedHandle.
///
///
/// PTS context
///
protected UnmanagedHandle(PtsContext ptsContext)
{
_ptsContext = ptsContext;
_handle = ptsContext.CreateHandle(this);
}
///
/// Dispose the object and release handle.
///
public virtual void Dispose()
{
try
{
_ptsContext.ReleaseHandle(_handle);
}
finally
{
_handle = IntPtr.Zero;
}
GC.SuppressFinalize(this);
}
///
/// Handle of an object.
///
internal IntPtr Handle
{
get
{
return _handle;
}
}
private IntPtr _handle;
///
/// PtsContext that is the owner of the handle.
/// It is required to store it here for Dispose. When Dispose is called
/// it is not always possible to get instance of PtsContext that
/// has been used to create this handle.
///
internal PtsContext PtsContext { get { return _ptsContext; } }
private readonly PtsContext _ptsContext;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Quad.cs
- ExpressionPrinter.cs
- dtdvalidator.cs
- LinqDataSourceUpdateEventArgs.cs
- TextTreeUndo.cs
- UnsafeNativeMethods.cs
- AstTree.cs
- DoubleLinkList.cs
- XmlValueConverter.cs
- ColorTransformHelper.cs
- SelectionItemPatternIdentifiers.cs
- ValidationRuleCollection.cs
- SqlProfileProvider.cs
- OdbcDataReader.cs
- AssemblyCache.cs
- SerializationEventsCache.cs
- CodeIndexerExpression.cs
- XPathAncestorQuery.cs
- SQLBoolean.cs
- StaticContext.cs
- FunctionQuery.cs
- DataRelation.cs
- Point3DCollection.cs
- propertyentry.cs
- SqlXml.cs
- WebException.cs
- WSUtilitySpecificationVersion.cs
- RegistryConfigurationProvider.cs
- SqlCommandBuilder.cs
- SettingsProperty.cs
- UrlPath.cs
- ConnectionPoint.cs
- SspiSecurityToken.cs
- XmlSecureResolver.cs
- Context.cs
- IsolationInterop.cs
- MexBindingBindingCollectionElement.cs
- XmlNamespaceManager.cs
- PropertyTab.cs
- CommandDevice.cs
- Light.cs
- TablePattern.cs
- GridViewCellAutomationPeer.cs
- SerialReceived.cs
- VectorCollection.cs
- SpellerHighlightLayer.cs
- GuidConverter.cs
- Brushes.cs
- PageThemeParser.cs
- OleDbRowUpdatingEvent.cs
- OracleConnection.cs
- WebPartConnectionsCancelVerb.cs
- TabControl.cs
- DeferredSelectedIndexReference.cs
- IndexedDataBuffer.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- UpdatePanelTrigger.cs
- Single.cs
- Queue.cs
- BlurBitmapEffect.cs
- RectangleF.cs
- MetafileHeader.cs
- CompositeDataBoundControl.cs
- DataGridViewCellLinkedList.cs
- ObjectConverter.cs
- ThreadExceptionEvent.cs
- ListItemCollection.cs
- AssociationTypeEmitter.cs
- WindowsListViewItemStartMenu.cs
- ParameterBuilder.cs
- CssTextWriter.cs
- MarkupCompiler.cs
- BamlLocalizabilityResolver.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- Membership.cs
- SerializerProvider.cs
- ViewBase.cs
- CriticalFinalizerObject.cs
- Typography.cs
- RequestCacheValidator.cs
- SizeF.cs
- PrimitiveSchema.cs
- EmptyTextWriter.cs
- BindingSource.cs
- WebPartZone.cs
- MediaPlayerState.cs
- Stylesheet.cs
- WebPartCollection.cs
- TableLayoutPanelCellPosition.cs
- SqlClientMetaDataCollectionNames.cs
- fixedPageContentExtractor.cs
- ResourceDisplayNameAttribute.cs
- XamlRtfConverter.cs
- RightNameExpirationInfoPair.cs
- WhereQueryOperator.cs
- DesignColumn.cs
- OracleBinary.cs
- Frame.cs
- ScrollItemPattern.cs
- OleDbRowUpdatingEvent.cs