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
- Inline.cs
- DPTypeDescriptorContext.cs
- WebAdminConfigurationHelper.cs
- Subset.cs
- AsymmetricKeyExchangeDeformatter.cs
- DynamicMethod.cs
- HashLookup.cs
- BulletDecorator.cs
- DefaultBinder.cs
- ActivityBindForm.Designer.cs
- XmlResolver.cs
- CodeGeneratorOptions.cs
- Aggregates.cs
- SchemaExporter.cs
- Timer.cs
- DataFieldConverter.cs
- WebPageTraceListener.cs
- RenameRuleObjectDialog.Designer.cs
- DataGridPageChangedEventArgs.cs
- DataGridColumnHeaderAutomationPeer.cs
- VersionedStreamOwner.cs
- LinqExpressionNormalizer.cs
- Int64.cs
- GrabHandleGlyph.cs
- ActivityDesignerAccessibleObject.cs
- NotSupportedException.cs
- UnicastIPAddressInformationCollection.cs
- WebPartHeaderCloseVerb.cs
- FunctionQuery.cs
- DocumentationServerProtocol.cs
- WaitHandle.cs
- TriggerBase.cs
- KeyboardEventArgs.cs
- SiteMapNode.cs
- Stacktrace.cs
- WebRequestModuleElementCollection.cs
- ComponentEditorPage.cs
- FileDialogPermission.cs
- RenameRuleObjectDialog.cs
- PrintingPermissionAttribute.cs
- HtmlImageAdapter.cs
- CompiledXpathExpr.cs
- CheckBoxFlatAdapter.cs
- EntityStoreSchemaFilterEntry.cs
- BitmapEffect.cs
- GeometryGroup.cs
- BitStack.cs
- XslCompiledTransform.cs
- SqlUdtInfo.cs
- FontClient.cs
- PageParserFilter.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- InvokeWebService.cs
- Viewport2DVisual3D.cs
- HtmlTable.cs
- HtmlValidationSummaryAdapter.cs
- ApplicationManager.cs
- PopupEventArgs.cs
- SecurityManager.cs
- SimpleMailWebEventProvider.cs
- ArrayElementGridEntry.cs
- ConfigurationValue.cs
- DependencyPropertyConverter.cs
- StateChangeEvent.cs
- WithParamAction.cs
- ContentDefinition.cs
- MatrixKeyFrameCollection.cs
- CapabilitiesUse.cs
- DataTableMapping.cs
- ToolStripLocationCancelEventArgs.cs
- XmlIterators.cs
- HttpRuntime.cs
- SR.cs
- CleanUpVirtualizedItemEventArgs.cs
- tibetanshape.cs
- CutCopyPasteHelper.cs
- SaveWorkflowCommand.cs
- WebServicesSection.cs
- EvidenceTypeDescriptor.cs
- SBCSCodePageEncoding.cs
- ImageIndexConverter.cs
- XmlQueryOutput.cs
- Native.cs
- ZipFileInfoCollection.cs
- UIElementIsland.cs
- NetNamedPipeSecurityMode.cs
- DataGridViewControlCollection.cs
- ControlCachePolicy.cs
- ComplexBindingPropertiesAttribute.cs
- PaperSource.cs
- NetStream.cs
- Single.cs
- LocatorPartList.cs
- ViewService.cs
- TypeSystem.cs
- WS2007HttpBinding.cs
- Geometry3D.cs
- WebPartPersonalization.cs
- UIElement3DAutomationPeer.cs
- ToolboxBitmapAttribute.cs