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
- QilNode.cs
- ComponentCollection.cs
- StylusPointPropertyUnit.cs
- XmlSerializerNamespaces.cs
- OleDbDataReader.cs
- XPathMultyIterator.cs
- TagElement.cs
- TemplateComponentConnector.cs
- DoWorkEventArgs.cs
- DtdParser.cs
- InvalidContentTypeException.cs
- IListConverters.cs
- OwnerDrawPropertyBag.cs
- BindUriHelper.cs
- recordstatescratchpad.cs
- PartitionedStreamMerger.cs
- RowVisual.cs
- XmlWriterDelegator.cs
- SiteMembershipCondition.cs
- DrawingVisualDrawingContext.cs
- XPathArrayIterator.cs
- ProtocolsConfigurationHandler.cs
- OracleTimeSpan.cs
- ExpressionBindingCollection.cs
- FunctionDescription.cs
- DefaultTextStore.cs
- MethodBuilderInstantiation.cs
- PropertyMetadata.cs
- MobileListItem.cs
- DateTimeFormat.cs
- HttpClientCredentialType.cs
- InvalidDataException.cs
- WindowsProgressbar.cs
- PropertyGrid.cs
- NameValuePair.cs
- UnicastIPAddressInformationCollection.cs
- EventsTab.cs
- PagesSection.cs
- ErrorInfoXmlDocument.cs
- Operand.cs
- RewritingValidator.cs
- QuaternionRotation3D.cs
- SQLUtility.cs
- LogLogRecordHeader.cs
- ConstructorNeedsTagAttribute.cs
- X509Utils.cs
- CollectionBuilder.cs
- QuaternionAnimation.cs
- PenThreadWorker.cs
- XmlNode.cs
- PrimarySelectionAdorner.cs
- Style.cs
- TypeResolver.cs
- HandoffBehavior.cs
- SplitterEvent.cs
- StateBag.cs
- TrackingStringDictionary.cs
- OperationContractGenerationContext.cs
- _ServiceNameStore.cs
- CharUnicodeInfo.cs
- InternalTransaction.cs
- DataServiceExpressionVisitor.cs
- RbTree.cs
- SystemThemeKey.cs
- DesignerTextWriter.cs
- RMEnrollmentPage3.cs
- storepermissionattribute.cs
- D3DImage.cs
- SafeMemoryMappedViewHandle.cs
- GridViewUpdatedEventArgs.cs
- OdbcParameter.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- UnsettableComboBox.cs
- HandlerFactoryCache.cs
- TextTreeDeleteContentUndoUnit.cs
- CryptoStream.cs
- CompilerTypeWithParams.cs
- ProviderCollection.cs
- MultiBinding.cs
- VisualTarget.cs
- CatalogPartDesigner.cs
- DecimalConstantAttribute.cs
- DoubleConverter.cs
- XmlSchemaAttributeGroupRef.cs
- XmlILModule.cs
- ValidatorUtils.cs
- ElementNotEnabledException.cs
- AspCompat.cs
- NotifyCollectionChangedEventArgs.cs
- TemplateNameScope.cs
- EntityDataSourceContextDisposingEventArgs.cs
- ProfileInfo.cs
- CompilerState.cs
- BrowserDefinition.cs
- COAUTHINFO.cs
- CqlLexer.cs
- BitmapEffectInputConnector.cs
- AsyncStreamReader.cs
- ComEventsInfo.cs