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
- HttpValueCollection.cs
- DesignerExtenders.cs
- NonBatchDirectoryCompiler.cs
- PropertyMap.cs
- InputScopeManager.cs
- SystemResourceHost.cs
- EntityDataSourceUtil.cs
- FirstMatchCodeGroup.cs
- ApplicationDirectory.cs
- KnowledgeBase.cs
- ListSurrogate.cs
- BamlResourceSerializer.cs
- SiteMapNodeItem.cs
- RowUpdatingEventArgs.cs
- WebPartZoneBase.cs
- ProfileSettings.cs
- MediaPlayerState.cs
- RootBrowserWindowProxy.cs
- ProxyGenerationError.cs
- SqlMethods.cs
- RegistrationProxy.cs
- ProxyWebPartConnectionCollection.cs
- SystemIPv6InterfaceProperties.cs
- Transform3D.cs
- CompiledELinqQueryState.cs
- FixedSOMLineRanges.cs
- Currency.cs
- DataServiceSaveChangesEventArgs.cs
- IsolatedStoragePermission.cs
- MiniConstructorInfo.cs
- HierarchicalDataBoundControl.cs
- DescendentsWalker.cs
- InvalidTimeZoneException.cs
- AssertHelper.cs
- DocumentViewer.cs
- ApplicationException.cs
- KeyboardEventArgs.cs
- ProfileBuildProvider.cs
- TraversalRequest.cs
- InternalBase.cs
- SessionKeyExpiredException.cs
- ScrollableControlDesigner.cs
- storepermissionattribute.cs
- ProfileGroupSettingsCollection.cs
- HtmlInputText.cs
- DataGridColumnDropSeparator.cs
- UnwrappedTypesXmlSerializerManager.cs
- BindingElementExtensionElement.cs
- DictionaryEntry.cs
- AdornerDecorator.cs
- SoundPlayer.cs
- SecurityContext.cs
- DBAsyncResult.cs
- DiagnosticTrace.cs
- ContextStaticAttribute.cs
- XPathSelectionIterator.cs
- LayoutSettings.cs
- SystemIPv6InterfaceProperties.cs
- OdbcInfoMessageEvent.cs
- HandlerBase.cs
- ImageDesigner.cs
- mediaeventshelper.cs
- MdiWindowListItemConverter.cs
- WebBrowserContainer.cs
- TraceContext.cs
- AutomationElementIdentifiers.cs
- ListBoxItemWrapperAutomationPeer.cs
- RequiredAttributeAttribute.cs
- EpmContentSerializer.cs
- SqlDataSourceStatusEventArgs.cs
- FloaterBaseParaClient.cs
- TraceProvider.cs
- Hash.cs
- DocumentOutline.cs
- SubclassTypeValidator.cs
- ProcessModelSection.cs
- linebase.cs
- DocumentReferenceCollection.cs
- TransformerInfoCollection.cs
- BitmapPalette.cs
- HtmlLiteralTextAdapter.cs
- ItemContainerGenerator.cs
- PartialArray.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- DataServiceResponse.cs
- DriveInfo.cs
- DataKey.cs
- NetMsmqBinding.cs
- GridLengthConverter.cs
- future.cs
- HitTestParameters.cs
- IdentityHolder.cs
- DataGridLinkButton.cs
- EventLogger.cs
- XPathConvert.cs
- LineBreakRecord.cs
- SocketInformation.cs
- Publisher.cs
- SinglePageViewer.cs
- BindingWorker.cs