Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / MS / Internal / PtsHost / UnmanagedHandle.cs / 1 / 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 : grzegorz - 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; } } ////// 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 : grzegorz - 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; } } ////// 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
- SafeProcessHandle.cs
- _LocalDataStoreMgr.cs
- DictionaryBase.cs
- Array.cs
- BooleanAnimationBase.cs
- Int32AnimationUsingKeyFrames.cs
- GridViewColumnCollection.cs
- RepeatBehaviorConverter.cs
- SafeEventLogWriteHandle.cs
- HtmlValidationSummaryAdapter.cs
- Stream.cs
- PointAnimationUsingKeyFrames.cs
- WebServicesSection.cs
- PrePrepareMethodAttribute.cs
- GridViewColumnCollectionChangedEventArgs.cs
- OverflowException.cs
- CharacterMetrics.cs
- ApplicationSettingsBase.cs
- UriTemplateTrieLocation.cs
- PasswordBox.cs
- TypeContext.cs
- Size.cs
- ProxySimple.cs
- Delegate.cs
- ThemeDirectoryCompiler.cs
- FileAuthorizationModule.cs
- SqlGenericUtil.cs
- DataListItemEventArgs.cs
- ButtonBaseAutomationPeer.cs
- AssertUtility.cs
- Composition.cs
- BindingContext.cs
- DateTimeOffset.cs
- LocatorPart.cs
- ToolStripContainer.cs
- PathStreamGeometryContext.cs
- DataBoundControlHelper.cs
- HttpCacheVaryByContentEncodings.cs
- KnownTypeAttribute.cs
- OdbcPermission.cs
- InternalBase.cs
- ArraySet.cs
- MetadataCache.cs
- StringExpressionSet.cs
- WebPartEditorApplyVerb.cs
- DeadCharTextComposition.cs
- ApplicationFileCodeDomTreeGenerator.cs
- HtmlTableRow.cs
- FacetValues.cs
- Manipulation.cs
- PreviewPageInfo.cs
- DependencyObjectPropertyDescriptor.cs
- EventMetadata.cs
- DynamicRenderer.cs
- CannotUnloadAppDomainException.cs
- HierarchicalDataTemplate.cs
- DoneReceivingAsyncResult.cs
- DbConnectionClosed.cs
- ContentOperations.cs
- WebPartChrome.cs
- DataRelation.cs
- HtmlImage.cs
- RoleManagerSection.cs
- unsafeIndexingFilterStream.cs
- MSAAEventDispatcher.cs
- OraclePermissionAttribute.cs
- GroupBoxRenderer.cs
- SrgsGrammarCompiler.cs
- OleDbDataReader.cs
- Storyboard.cs
- SequenceDesigner.cs
- ScopedKnownTypes.cs
- Authorization.cs
- SelectionManager.cs
- SQLDateTimeStorage.cs
- RelationshipManager.cs
- Descriptor.cs
- ControlCachePolicy.cs
- SqlVersion.cs
- InvalidComObjectException.cs
- MemberCollection.cs
- EventMap.cs
- NgenServicingAttributes.cs
- FunctionQuery.cs
- DataRow.cs
- PostBackTrigger.cs
- DispatchProxy.cs
- SmiGettersStream.cs
- controlskin.cs
- LabelEditEvent.cs
- ToggleProviderWrapper.cs
- PartialToken.cs
- SqlCommandBuilder.cs
- MbpInfo.cs
- SecurityHelper.cs
- URLAttribute.cs
- AuthenticatedStream.cs
- DataGridViewRowHeaderCell.cs
- MouseGesture.cs
- UIElement.cs