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
- LocalizableResourceBuilder.cs
- FormViewRow.cs
- DbMetaDataFactory.cs
- Command.cs
- JoinTreeNode.cs
- GeneralTransform3D.cs
- InputBinding.cs
- ipaddressinformationcollection.cs
- DynamicFilterExpression.cs
- EntityViewContainer.cs
- _Semaphore.cs
- ToolStripDropDownMenu.cs
- PrinterResolution.cs
- GatewayDefinition.cs
- XmlElement.cs
- XPathAxisIterator.cs
- StackBuilderSink.cs
- XmlSchemaCollection.cs
- PeerIPHelper.cs
- BitmapSizeOptions.cs
- PropertyGroupDescription.cs
- EventRoute.cs
- CompensationHandlingFilter.cs
- DocumentViewerBase.cs
- IsolatedStoragePermission.cs
- BindingManagerDataErrorEventArgs.cs
- ContainerVisual.cs
- autovalidator.cs
- SqlTriggerContext.cs
- ModifierKeysValueSerializer.cs
- MutexSecurity.cs
- COM2PictureConverter.cs
- _SafeNetHandles.cs
- TextBounds.cs
- LabelDesigner.cs
- DoubleCollectionConverter.cs
- WriterOutput.cs
- BasicHttpSecurityElement.cs
- RadialGradientBrush.cs
- typedescriptorpermission.cs
- XmlDataSourceNodeDescriptor.cs
- FeatureSupport.cs
- DataPagerField.cs
- ExpressionVisitor.cs
- DrawingState.cs
- AppSettingsSection.cs
- ProviderSettingsCollection.cs
- ScriptResourceAttribute.cs
- ReflectionTypeLoadException.cs
- InputQueue.cs
- Update.cs
- WinFormsUtils.cs
- RepeaterCommandEventArgs.cs
- SchemaComplexType.cs
- SessionStateItemCollection.cs
- propertytag.cs
- SqlColumnizer.cs
- ControlParser.cs
- SerialStream.cs
- Expression.cs
- ModuleBuilderData.cs
- LoginUtil.cs
- DataDocumentXPathNavigator.cs
- ColumnReorderedEventArgs.cs
- UnionCodeGroup.cs
- UpdatePanel.cs
- XmlStreamedByteStreamReader.cs
- ReferentialConstraint.cs
- MultilineStringConverter.cs
- SystemIcons.cs
- FirstMatchCodeGroup.cs
- JsonCollectionDataContract.cs
- BasicViewGenerator.cs
- _UncName.cs
- SqlUtils.cs
- ListViewTableRow.cs
- TrimSurroundingWhitespaceAttribute.cs
- MenuItem.cs
- HttpFileCollectionWrapper.cs
- SqlProfileProvider.cs
- StreamGeometry.cs
- SHA256Managed.cs
- CatalogZone.cs
- Quaternion.cs
- TraceSection.cs
- XmlConverter.cs
- elementinformation.cs
- XmlRawWriterWrapper.cs
- ServiceSecurityContext.cs
- XhtmlBasicFormAdapter.cs
- wgx_commands.cs
- CustomErrorsSectionWrapper.cs
- Trustee.cs
- CommandPlan.cs
- TextSpan.cs
- FormattedTextSymbols.cs
- OperationResponse.cs
- SuppressMergeCheckAttribute.cs
- HtmlImage.cs
- RuntimeConfig.cs