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
- DrawingAttributeSerializer.cs
- HostExecutionContextManager.cs
- ContentPosition.cs
- Renderer.cs
- SmtpFailedRecipientsException.cs
- RtfToXamlReader.cs
- IndentedTextWriter.cs
- FamilyTypefaceCollection.cs
- TerminatorSinks.cs
- EnumType.cs
- SetStateDesigner.cs
- TextCollapsingProperties.cs
- EventEntry.cs
- ContextMenuStrip.cs
- IndependentlyAnimatedPropertyMetadata.cs
- DiscoveryClientProtocol.cs
- WorkflowPersistenceService.cs
- LineBreak.cs
- DbInsertCommandTree.cs
- UIElementCollection.cs
- WebServiceEnumData.cs
- ExtensionsSection.cs
- SizeValueSerializer.cs
- graph.cs
- NullRuntimeConfig.cs
- DecimalStorage.cs
- KnownTypesProvider.cs
- PointF.cs
- DataServices.cs
- ViewCellSlot.cs
- MasterPageBuildProvider.cs
- SettingsPropertyCollection.cs
- VirtualizingPanel.cs
- SymLanguageType.cs
- DataTable.cs
- IgnoreSectionHandler.cs
- AttributeSetAction.cs
- NotSupportedException.cs
- Events.cs
- CodeThrowExceptionStatement.cs
- BamlReader.cs
- DataGridViewIntLinkedList.cs
- StylusSystemGestureEventArgs.cs
- XsltSettings.cs
- ConfigPathUtility.cs
- TypeCacheManager.cs
- RMPublishingDialog.cs
- BitmapMetadataEnumerator.cs
- Drawing.cs
- StoreItemCollection.Loader.cs
- xmlsaver.cs
- HtmlInputImage.cs
- Configuration.cs
- BufferedStream.cs
- XslAstAnalyzer.cs
- MappingException.cs
- EntityType.cs
- HttpWebRequest.cs
- ImageMapEventArgs.cs
- SchemaConstraints.cs
- Events.cs
- TagMapCollection.cs
- HtmlPanelAdapter.cs
- DictionaryEntry.cs
- NumericUpDown.cs
- DockingAttribute.cs
- HttpDictionary.cs
- DataGridRelationshipRow.cs
- DataGrid.cs
- ProxyWebPartConnectionCollection.cs
- DataGridViewBindingCompleteEventArgs.cs
- Binding.cs
- SqlUtil.cs
- HotCommands.cs
- SQLBinaryStorage.cs
- PenLineJoinValidation.cs
- CallContext.cs
- DocumentViewerBaseAutomationPeer.cs
- UnicastIPAddressInformationCollection.cs
- NameValueFileSectionHandler.cs
- DataTableMappingCollection.cs
- DbSource.cs
- SqlDataSourceEnumerator.cs
- AlternateViewCollection.cs
- ScrollChangedEventArgs.cs
- Triplet.cs
- BinaryConverter.cs
- SectionVisual.cs
- TraceSwitch.cs
- UidPropertyAttribute.cs
- SystemIPv4InterfaceProperties.cs
- XmlSchemaDatatype.cs
- IERequestCache.cs
- SQLInt16Storage.cs
- OleCmdHelper.cs
- Vector3DCollectionConverter.cs
- FontUnitConverter.cs
- KoreanCalendar.cs
- TextEditorSpelling.cs
- MouseDevice.cs