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
- DropShadowBitmapEffect.cs
- ContractAdapter.cs
- DBSqlParser.cs
- MultipartIdentifier.cs
- XhtmlBasicValidatorAdapter.cs
- Focus.cs
- DataServiceEntityAttribute.cs
- WorkflowFileItem.cs
- VirtualPathExtension.cs
- WebHttpSecurity.cs
- TabItemWrapperAutomationPeer.cs
- smtpconnection.cs
- DetailsViewInsertEventArgs.cs
- processwaithandle.cs
- GridViewUpdateEventArgs.cs
- SignatureHelper.cs
- WebPartEditorApplyVerb.cs
- DragDropHelper.cs
- GrammarBuilderBase.cs
- ForeignConstraint.cs
- ObjectDataSourceDisposingEventArgs.cs
- EmbeddedMailObjectsCollection.cs
- ISCIIEncoding.cs
- HierarchicalDataTemplate.cs
- DBConcurrencyException.cs
- ToolboxDataAttribute.cs
- ContainerUIElement3D.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- ConfigUtil.cs
- ActiveDocumentEvent.cs
- AnimationLayer.cs
- ScrollBarRenderer.cs
- CodeSubDirectoriesCollection.cs
- DocumentViewerConstants.cs
- SeekableMessageNavigator.cs
- smtpconnection.cs
- SQLInt64.cs
- DefaultValueAttribute.cs
- HwndSubclass.cs
- KeyboardEventArgs.cs
- Animatable.cs
- StylusPointDescription.cs
- ServiceReference.cs
- IPAddress.cs
- GridViewEditEventArgs.cs
- DefaultPropertyAttribute.cs
- DocumentViewerHelper.cs
- Window.cs
- FilterEventArgs.cs
- RemotingConfigParser.cs
- SqlException.cs
- ServicePointManagerElement.cs
- FontStyle.cs
- ListViewInsertionMark.cs
- HtmlElementEventArgs.cs
- DataGridViewBindingCompleteEventArgs.cs
- XamlStream.cs
- JavaScriptString.cs
- WindowsFormsHostPropertyMap.cs
- EntityDataReader.cs
- unsafenativemethodsother.cs
- MenuCommand.cs
- WebServicesInteroperability.cs
- MD5.cs
- Track.cs
- SafeArrayRankMismatchException.cs
- MatrixAnimationUsingKeyFrames.cs
- RuntimeVariablesExpression.cs
- LicenseContext.cs
- IndentedWriter.cs
- XmlSchemaAll.cs
- XPathNodeList.cs
- ScaleTransform.cs
- httpstaticobjectscollection.cs
- FlowPosition.cs
- SafeEventLogWriteHandle.cs
- SortedList.cs
- precedingsibling.cs
- BuildResultCache.cs
- EventDescriptorCollection.cs
- TouchFrameEventArgs.cs
- XpsSerializerWriter.cs
- ReceiveDesigner.xaml.cs
- DataGridViewTextBoxCell.cs
- Size3D.cs
- Evidence.cs
- DesignerTransaction.cs
- ListenerConstants.cs
- HttpRuntime.cs
- EnlistmentState.cs
- RightNameExpirationInfoPair.cs
- ParentQuery.cs
- DynamicRendererThreadManager.cs
- SqlInternalConnectionSmi.cs
- ProcessHostMapPath.cs
- ButtonPopupAdapter.cs
- DiscreteKeyFrames.cs
- UnsafeNativeMethods.cs
- CultureInfoConverter.cs
- ListControlBuilder.cs