Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- EntityViewContainer.cs
- SoapAttributes.cs
- OrderPreservingPipeliningSpoolingTask.cs
- IsolationInterop.cs
- XslAstAnalyzer.cs
- Config.cs
- CompModHelpers.cs
- CurrentTimeZone.cs
- DataSetUtil.cs
- MethodCallConverter.cs
- DelayedRegex.cs
- ValuePatternIdentifiers.cs
- serverconfig.cs
- WorkflowTransactionOptions.cs
- DispatcherObject.cs
- ImagingCache.cs
- DataBoundControl.cs
- PackagePart.cs
- UpdateManifestForBrowserApplication.cs
- EnumBuilder.cs
- TableAutomationPeer.cs
- DurableOperationContext.cs
- documentsequencetextview.cs
- AnnotationComponentManager.cs
- SiblingIterators.cs
- XmlSigningNodeWriter.cs
- Timeline.cs
- SourceFileBuildProvider.cs
- DbConnectionHelper.cs
- ScrollChrome.cs
- PaginationProgressEventArgs.cs
- StatusBar.cs
- CalloutQueueItem.cs
- ConfigXmlWhitespace.cs
- EventProviderBase.cs
- IndicFontClient.cs
- TranslateTransform3D.cs
- DefaultValueConverter.cs
- OracleConnectionStringBuilder.cs
- MemoryStream.cs
- DefaultObjectMappingItemCollection.cs
- XslAst.cs
- CheckBoxFlatAdapter.cs
- NativeObjectSecurity.cs
- BasicCellRelation.cs
- CustomErrorsSectionWrapper.cs
- RelationshipWrapper.cs
- EncoderExceptionFallback.cs
- SelectionRange.cs
- GridViewSortEventArgs.cs
- Crc32.cs
- Substitution.cs
- ClientRuntimeConfig.cs
- CopyOnWriteList.cs
- PeerCollaboration.cs
- CodeTryCatchFinallyStatement.cs
- VirtualizingStackPanel.cs
- PropertyTab.cs
- FieldToken.cs
- PrintPreviewControl.cs
- RoutedPropertyChangedEventArgs.cs
- dbdatarecord.cs
- ParserStreamGeometryContext.cs
- TrustSection.cs
- RoleExceptions.cs
- IgnoreDataMemberAttribute.cs
- DebugViewWriter.cs
- XamlParser.cs
- HandlerBase.cs
- BindingCollection.cs
- GroupBox.cs
- BrowserTree.cs
- PathNode.cs
- ListItemsPage.cs
- ArraySortHelper.cs
- ResourceDescriptionAttribute.cs
- Exceptions.cs
- RtfToken.cs
- ImageConverter.cs
- FrameworkReadOnlyPropertyMetadata.cs
- SpellerError.cs
- DelegatingConfigHost.cs
- EDesignUtil.cs
- PermissionListSet.cs
- ToolboxCategory.cs
- AliasGenerator.cs
- ScaleTransform.cs
- TreePrinter.cs
- XomlCompiler.cs
- SelectionItemProviderWrapper.cs
- SchemaNames.cs
- GB18030Encoding.cs
- SchemaNames.cs
- TagMapCollection.cs
- CommandValueSerializer.cs
- InvalidProgramException.cs
- WindowsAuthenticationModule.cs
- HttpListenerRequestUriBuilder.cs
- Certificate.cs
- SQLDateTimeStorage.cs