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
- ProgressiveCrcCalculatingStream.cs
- ListChangedEventArgs.cs
- EntityException.cs
- DataServiceClientException.cs
- SqlUdtInfo.cs
- PrimitiveCodeDomSerializer.cs
- ColumnTypeConverter.cs
- FlagsAttribute.cs
- StyleHelper.cs
- HebrewCalendar.cs
- HtmlInputFile.cs
- MarkupWriter.cs
- XslAst.cs
- CodeExporter.cs
- CommandSet.cs
- ArrayExtension.cs
- AxHost.cs
- DataGridViewButtonColumn.cs
- HttpProxyCredentialType.cs
- GeneralTransform3DTo2D.cs
- PolyLineSegment.cs
- TransformValueSerializer.cs
- DbDataSourceEnumerator.cs
- SurrogateDataContract.cs
- Annotation.cs
- Stacktrace.cs
- IndexedEnumerable.cs
- ACE.cs
- ReaderContextStackData.cs
- Helper.cs
- ListManagerBindingsCollection.cs
- XmlLanguage.cs
- ColorMatrix.cs
- TracedNativeMethods.cs
- ModelTreeEnumerator.cs
- DataColumnPropertyDescriptor.cs
- SymbolEqualComparer.cs
- EventProviderWriter.cs
- D3DImage.cs
- DataSourceControl.cs
- FolderLevelBuildProviderCollection.cs
- RelationshipWrapper.cs
- RNGCryptoServiceProvider.cs
- TrackPoint.cs
- SmiXetterAccessMap.cs
- XmlSchemaAttributeGroupRef.cs
- GenericTypeParameterConverter.cs
- EventPropertyMap.cs
- KeyboardDevice.cs
- StrokeCollectionDefaultValueFactory.cs
- AssemblyCache.cs
- DataGridViewColumnDesignTimeVisibleAttribute.cs
- HttpCookieCollection.cs
- KeyValueInternalCollection.cs
- XmlSchemaProviderAttribute.cs
- WinInet.cs
- Interlocked.cs
- DBCommandBuilder.cs
- DefaultPrintController.cs
- GeometryValueSerializer.cs
- Expressions.cs
- ReliableOutputConnection.cs
- initElementDictionary.cs
- CodeTypeReference.cs
- ConnectionProviderAttribute.cs
- ArgumentValueSerializer.cs
- SafeThreadHandle.cs
- UnicastIPAddressInformationCollection.cs
- RangeContentEnumerator.cs
- ClientScriptManagerWrapper.cs
- EditingScope.cs
- messageonlyhwndwrapper.cs
- SQLInt16Storage.cs
- ComponentConverter.cs
- Exceptions.cs
- XmlSchemaSimpleTypeList.cs
- Decimal.cs
- QueryCursorEventArgs.cs
- CompositeControl.cs
- SafeViewOfFileHandle.cs
- ServiceModelTimeSpanValidator.cs
- FormattedTextSymbols.cs
- Attachment.cs
- PropertyGeneratedEventArgs.cs
- APCustomTypeDescriptor.cs
- ExclusiveCanonicalizationTransform.cs
- MasterPageBuildProvider.cs
- HtmlTable.cs
- SchemaImporterExtensionElementCollection.cs
- ElementMarkupObject.cs
- SymbolDocumentGenerator.cs
- SqlWorkflowPersistenceService.cs
- OrderedDictionaryStateHelper.cs
- SettingsBase.cs
- CodeDOMProvider.cs
- DomNameTable.cs
- XmlElementAttributes.cs
- ConstructorNeedsTagAttribute.cs
- ReverseInheritProperty.cs
- AssemblyBuilder.cs