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
- HostedElements.cs
- TypeToTreeConverter.cs
- SoapElementAttribute.cs
- ContextMenuStripGroupCollection.cs
- ValueUtilsSmi.cs
- TrackBar.cs
- DrawingContextDrawingContextWalker.cs
- WSFederationHttpSecurity.cs
- RemotingException.cs
- DefaultObjectMappingItemCollection.cs
- InvokerUtil.cs
- Opcode.cs
- SafeArrayRankMismatchException.cs
- DrawingGroup.cs
- EntityDataSourceQueryBuilder.cs
- SchemaDeclBase.cs
- RequestChannel.cs
- CompatibleComparer.cs
- Globals.cs
- ScrollableControl.cs
- MobileControlDesigner.cs
- GridLength.cs
- ControlIdConverter.cs
- FontUnit.cs
- DbConnectionPoolGroup.cs
- RegionData.cs
- ListItemDetailViewAttribute.cs
- MissingFieldException.cs
- TextRenderer.cs
- StylusCollection.cs
- SiteMapHierarchicalDataSourceView.cs
- PagerSettings.cs
- WebPartDeleteVerb.cs
- Region.cs
- XmlWellformedWriter.cs
- FrameAutomationPeer.cs
- Itemizer.cs
- CodeExpressionCollection.cs
- NamespaceQuery.cs
- DbMetaDataColumnNames.cs
- IOException.cs
- SafeCoTaskMem.cs
- MissingMemberException.cs
- Figure.cs
- AnonymousIdentificationModule.cs
- CacheEntry.cs
- AsymmetricKeyExchangeDeformatter.cs
- DataGridViewCellMouseEventArgs.cs
- HttpCacheParams.cs
- ProgressBar.cs
- XmlWrappingWriter.cs
- SettingsPropertyNotFoundException.cs
- XmlSchemaAnyAttribute.cs
- StylusButtonCollection.cs
- Match.cs
- PassportAuthenticationEventArgs.cs
- PrintPreviewDialog.cs
- BuiltInPermissionSets.cs
- TagNameToTypeMapper.cs
- ETagAttribute.cs
- ChtmlSelectionListAdapter.cs
- LinkUtilities.cs
- CompileXomlTask.cs
- ServicesUtilities.cs
- InfoCardTrace.cs
- StringPropertyBuilder.cs
- MbpInfo.cs
- Timeline.cs
- TableRow.cs
- ControlEvent.cs
- ADMembershipUser.cs
- MapPathBasedVirtualPathProvider.cs
- EnvironmentPermission.cs
- DataExpression.cs
- PropertyPanel.cs
- SqlUdtInfo.cs
- SessionStateContainer.cs
- _DisconnectOverlappedAsyncResult.cs
- XmlCDATASection.cs
- TableLayoutCellPaintEventArgs.cs
- ChainOfResponsibility.cs
- DBParameter.cs
- Size.cs
- CodeDOMProvider.cs
- ValidationRuleCollection.cs
- MetadataException.cs
- TextEffect.cs
- InstanceCreationEditor.cs
- PartialArray.cs
- IISMapPath.cs
- XmlQueryType.cs
- login.cs
- TrackingServices.cs
- DataGridViewRowCancelEventArgs.cs
- RevocationPoint.cs
- WebZone.cs
- GroupBoxRenderer.cs
- RegistryConfigurationProvider.cs
- DataGridColumn.cs
- SelectedDatesCollection.cs