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
- ManipulationBoundaryFeedbackEventArgs.cs
- ReceiveParametersContent.cs
- GraphicsState.cs
- RangeValidator.cs
- ProtectedConfigurationSection.cs
- SystemPens.cs
- ApplicationContext.cs
- DataStreams.cs
- DataGridViewAdvancedBorderStyle.cs
- XmlILConstructAnalyzer.cs
- VectorValueSerializer.cs
- ErrorTolerantObjectWriter.cs
- ProgressBarBrushConverter.cs
- MailAddressCollection.cs
- Int16Storage.cs
- UserControlBuildProvider.cs
- AppDomainManager.cs
- Rule.cs
- BridgeDataRecord.cs
- StorageTypeMapping.cs
- Attachment.cs
- ToolStripItem.cs
- DemultiplexingClientMessageFormatter.cs
- IChannel.cs
- HuffmanTree.cs
- Application.cs
- AsyncPostBackErrorEventArgs.cs
- SR.Designer.cs
- BoundConstants.cs
- RouteParser.cs
- PageVisual.cs
- FormatterConverter.cs
- Delay.cs
- SerializationTrace.cs
- DataGridTextBoxColumn.cs
- MethodRental.cs
- CheckBoxRenderer.cs
- CodeMemberField.cs
- DoubleAnimationClockResource.cs
- WCFServiceClientProxyGenerator.cs
- RangeExpression.cs
- EntryIndex.cs
- AdapterDictionary.cs
- ItemDragEvent.cs
- CustomCredentialPolicy.cs
- ManifestResourceInfo.cs
- XmlSchemaAnnotated.cs
- WebPartDescription.cs
- DbProviderFactories.cs
- WorkflowInstanceTerminatedRecord.cs
- TemplateControlParser.cs
- BasicViewGenerator.cs
- XmlQueryOutput.cs
- TypeDescriptionProviderAttribute.cs
- SessionSymmetricMessageSecurityProtocolFactory.cs
- X509RawDataKeyIdentifierClause.cs
- CollectionDataContract.cs
- HtmlElementErrorEventArgs.cs
- DesignerWithHeader.cs
- ImageInfo.cs
- Stack.cs
- ExceptionUtil.cs
- Mouse.cs
- DataServiceQueryOfT.cs
- Stack.cs
- NamedObject.cs
- XmlSigningNodeWriter.cs
- PropertyEmitterBase.cs
- ContentPlaceHolder.cs
- CollectionConverter.cs
- dbenumerator.cs
- UserControl.cs
- DispatcherSynchronizationContext.cs
- oledbconnectionstring.cs
- BaseTemplateCodeDomTreeGenerator.cs
- X509Utils.cs
- CopyCodeAction.cs
- SerializationSectionGroup.cs
- WindowsRichEdit.cs
- Graph.cs
- PersonalizationProvider.cs
- ThreadExceptionDialog.cs
- TypeDescriptionProvider.cs
- SequentialWorkflowRootDesigner.cs
- TreeNodeBindingCollection.cs
- TableChangeProcessor.cs
- ElementInit.cs
- FileVersion.cs
- TcpChannelFactory.cs
- Trigger.cs
- TreeWalkHelper.cs
- SqlDataSourceCommandEventArgs.cs
- TypeLoadException.cs
- DefaultTraceListener.cs
- DirectoryObjectSecurity.cs
- ManifestResourceInfo.cs
- CompositeControl.cs
- EndOfStreamException.cs
- FormsAuthenticationCredentials.cs
- UserNameSecurityTokenProvider.cs