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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SortKey.cs
- OleDbConnection.cs
- ComponentResourceKey.cs
- Internal.cs
- UnionExpr.cs
- OpCopier.cs
- DataGridViewCellConverter.cs
- RegexMatch.cs
- PersonalizationStateQuery.cs
- GregorianCalendarHelper.cs
- ScaleTransform3D.cs
- ListSortDescriptionCollection.cs
- TextCompositionEventArgs.cs
- VectorCollection.cs
- Listbox.cs
- AnnotationElement.cs
- SourceChangedEventArgs.cs
- OdbcRowUpdatingEvent.cs
- XmlObjectSerializerWriteContextComplex.cs
- RelationshipManager.cs
- XmlSchemaSimpleTypeUnion.cs
- XamlUtilities.cs
- SafeArrayRankMismatchException.cs
- SelectionHighlightInfo.cs
- MessageContractImporter.cs
- assemblycache.cs
- IImplicitResourceProvider.cs
- DataTableClearEvent.cs
- DataGridHyperlinkColumn.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- DelegatingConfigHost.cs
- ApplicationTrust.cs
- SrgsSubset.cs
- ListViewItemSelectionChangedEvent.cs
- NativeMethods.cs
- UTF8Encoding.cs
- WebPartMinimizeVerb.cs
- ActiveXMessageFormatter.cs
- Scene3D.cs
- HeaderedContentControl.cs
- ReflectEventDescriptor.cs
- DotAtomReader.cs
- TransformDescriptor.cs
- EnumBuilder.cs
- AsyncOperationContext.cs
- TreeNodeStyle.cs
- TraceData.cs
- VsPropertyGrid.cs
- XamlReader.cs
- ServerValidateEventArgs.cs
- LicenseException.cs
- QueryCacheKey.cs
- JsonDeserializer.cs
- NullableIntSumAggregationOperator.cs
- RectangleF.cs
- StandardRuntimeEnumValidator.cs
- MulticastDelegate.cs
- ImageButton.cs
- CancelEventArgs.cs
- CommentEmitter.cs
- SelectionHighlightInfo.cs
- KeyNotFoundException.cs
- DataGridViewAdvancedBorderStyle.cs
- InertiaRotationBehavior.cs
- XmlCharType.cs
- XmlNodeChangedEventManager.cs
- DispatcherFrame.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- PopupRootAutomationPeer.cs
- ElementNotEnabledException.cs
- OracleDateTime.cs
- IPPacketInformation.cs
- DataGridColumnCollection.cs
- ErrorTableItemStyle.cs
- EndpointPerformanceCounters.cs
- SynchronousReceiveBehavior.cs
- BinaryObjectWriter.cs
- TextTreePropertyUndoUnit.cs
- ComponentDispatcherThread.cs
- BoolExpr.cs
- XmlAttributeHolder.cs
- EventHandlersStore.cs
- RuntimeResourceSet.cs
- securitycriticaldata.cs
- ObjectDataSourceFilteringEventArgs.cs
- OSFeature.cs
- SQLInt64.cs
- TextElementEditingBehaviorAttribute.cs
- CharacterBufferReference.cs
- DataGridViewCellStyle.cs
- DuplicateDetector.cs
- ArgumentException.cs
- ComponentDispatcher.cs
- ExpressionBuilderCollection.cs
- Panel.cs
- ReadonlyMessageFilter.cs
- SqlComparer.cs
- FastEncoder.cs
- NavigationProperty.cs
- ListBoxAutomationPeer.cs