Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- SmtpLoginAuthenticationModule.cs
- ConstructorBuilder.cs
- RayHitTestParameters.cs
- Cell.cs
- UrlPath.cs
- DesignerHelpers.cs
- EndPoint.cs
- ExpressionQuoter.cs
- SoapMessage.cs
- ReadOnlyHierarchicalDataSource.cs
- PaintEvent.cs
- AuthenticationModuleElementCollection.cs
- BoundConstants.cs
- SyndicationContent.cs
- QueryReaderSettings.cs
- RelationshipSet.cs
- ParentUndoUnit.cs
- NativeMethods.cs
- ListenerElementsCollection.cs
- WebPartDescription.cs
- StrongNameHelpers.cs
- TextureBrush.cs
- ByteAnimationBase.cs
- ImmutableCollection.cs
- XmlText.cs
- CryptoApi.cs
- PeerNodeTraceRecord.cs
- Terminate.cs
- ProfileGroupSettings.cs
- ValidatingPropertiesEventArgs.cs
- DescendentsWalkerBase.cs
- WinFormsUtils.cs
- TextReader.cs
- ToolStripTextBox.cs
- DaylightTime.cs
- AQNBuilder.cs
- IndentedWriter.cs
- TextLine.cs
- BindValidator.cs
- _SslStream.cs
- ListViewSortEventArgs.cs
- TraceProvider.cs
- SqlDataSourceFilteringEventArgs.cs
- DBCSCodePageEncoding.cs
- RequestCacheEntry.cs
- TablePattern.cs
- Panel.cs
- XmlException.cs
- StylusPointPropertyId.cs
- CompModSwitches.cs
- RepeatBehavior.cs
- InstanceDataCollectionCollection.cs
- CalendarSelectionChangedEventArgs.cs
- FixedLineResult.cs
- DateTimeConverter2.cs
- ProvideValueServiceProvider.cs
- MultiBinding.cs
- RotateTransform.cs
- ImageCodecInfoPrivate.cs
- SeparatorAutomationPeer.cs
- ArrayItemValue.cs
- RealizedColumnsBlock.cs
- EntityType.cs
- PtsHelper.cs
- URIFormatException.cs
- NumberSubstitution.cs
- BamlRecords.cs
- RewritingValidator.cs
- Single.cs
- SpeechSynthesizer.cs
- StylusPointProperty.cs
- AttributeProviderAttribute.cs
- BinaryUtilClasses.cs
- ServiceControllerDesigner.cs
- AttributeCollection.cs
- BmpBitmapDecoder.cs
- DispatcherHookEventArgs.cs
- UInt16Storage.cs
- ThrowOnMultipleAssignment.cs
- TaiwanCalendar.cs
- MultiBindingExpression.cs
- DiscoveryEndpointValidator.cs
- entityreference_tresulttype.cs
- XmlNamespaceMappingCollection.cs
- HealthMonitoringSection.cs
- DataColumnChangeEvent.cs
- Context.cs
- login.cs
- WebPartTransformerAttribute.cs
- WrappedReader.cs
- XNodeNavigator.cs
- UnionQueryOperator.cs
- CheckBoxPopupAdapter.cs
- Literal.cs
- SqlDataReaderSmi.cs
- VersionedStreamOwner.cs
- DataSourceView.cs
- EventMappingSettingsCollection.cs
- DrawListViewItemEventArgs.cs
- TemplatedEditableDesignerRegion.cs