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
- ReverseComparer.cs
- SessionStateSection.cs
- IntSecurity.cs
- ExpressionBinding.cs
- JoinSymbol.cs
- FilteredAttributeCollection.cs
- ComponentResourceKeyConverter.cs
- EnlistmentState.cs
- SwitchAttribute.cs
- MemberMaps.cs
- XamlValidatingReader.cs
- XmlSchemaFacet.cs
- WebServiceEnumData.cs
- NumberAction.cs
- SemanticBasicElement.cs
- StandardToolWindows.cs
- SafeFileMapViewHandle.cs
- SelectorItemAutomationPeer.cs
- TextBox.cs
- ItemPager.cs
- ProvidePropertyAttribute.cs
- ConnectionPointCookie.cs
- MailAddressCollection.cs
- XmlBinaryWriterSession.cs
- _NegoState.cs
- HotSpotCollection.cs
- CaseInsensitiveOrdinalStringComparer.cs
- ZoneIdentityPermission.cs
- XmlNamespaceMapping.cs
- ProcessProtocolHandler.cs
- WebPartEditVerb.cs
- GroupStyle.cs
- CodeRemoveEventStatement.cs
- LogConverter.cs
- OutputCacheProfile.cs
- SerTrace.cs
- DataSourceGeneratorException.cs
- DesignerSerializationVisibilityAttribute.cs
- ControlBuilderAttribute.cs
- ByteAnimationBase.cs
- AspProxy.cs
- IPipelineRuntime.cs
- UseManagedPresentationBindingElement.cs
- XsltSettings.cs
- WebBrowserDocumentCompletedEventHandler.cs
- LingerOption.cs
- MultipartContentParser.cs
- XmlSchemaParticle.cs
- QilInvokeLateBound.cs
- ServicePointManager.cs
- LinqExpressionNormalizer.cs
- StylusPointPropertyInfoDefaults.cs
- ErrorLog.cs
- LinqExpressionNormalizer.cs
- NavigationWindow.cs
- TableLayoutColumnStyleCollection.cs
- SecurityRuntime.cs
- CultureTable.cs
- FaultImportOptions.cs
- PathFigureCollection.cs
- ScopelessEnumAttribute.cs
- RelationshipEndMember.cs
- SizeLimitedCache.cs
- SmtpNegotiateAuthenticationModule.cs
- Nodes.cs
- PageContent.cs
- XPathNodeList.cs
- MobileErrorInfo.cs
- RelationalExpressions.cs
- DataGridViewCellEventArgs.cs
- SharedUtils.cs
- PropertyGrid.cs
- ConfigUtil.cs
- ListViewDataItem.cs
- Walker.cs
- SystemNetHelpers.cs
- CachedCompositeFamily.cs
- ManagementObject.cs
- SplitContainerDesigner.cs
- NavigationService.cs
- StorageAssociationTypeMapping.cs
- OutputCacheSettingsSection.cs
- ConditionalExpression.cs
- ValidationHelper.cs
- ObjectAnimationUsingKeyFrames.cs
- MetadataItem_Static.cs
- RandomNumberGenerator.cs
- FileDataSourceCache.cs
- LogEntryHeaderv1Deserializer.cs
- Directory.cs
- ProxyWebPart.cs
- Pointer.cs
- DetailsViewPagerRow.cs
- HtmlDocument.cs
- XmlByteStreamReader.cs
- XmlText.cs
- MergePropertyDescriptor.cs
- ConfigurationManagerHelper.cs
- PropertyEmitterBase.cs
- EntityDataSourceColumn.cs