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
- ValidationHelper.cs
- TokenBasedSetEnumerator.cs
- MessageRpc.cs
- SHA384.cs
- DetailsViewPagerRow.cs
- SeekStoryboard.cs
- StringComparer.cs
- SmiEventSink_DeferedProcessing.cs
- CodeVariableReferenceExpression.cs
- ResourceManager.cs
- WindowsFormsLinkLabel.cs
- SqlDataReaderSmi.cs
- returneventsaver.cs
- BinaryFormatter.cs
- SelectionItemProviderWrapper.cs
- CustomErrorCollection.cs
- BitmapMetadataBlob.cs
- RuleDefinitions.cs
- HtmlElementEventArgs.cs
- SafeEventLogReadHandle.cs
- Byte.cs
- HMACSHA1.cs
- ValueType.cs
- HtmlForm.cs
- WizardPanelChangingEventArgs.cs
- FactoryMaker.cs
- GlobalItem.cs
- RequestCachePolicy.cs
- FontFamilyValueSerializer.cs
- DataGridCell.cs
- X509PeerCertificateAuthentication.cs
- DrawingVisualDrawingContext.cs
- Floater.cs
- COM2ComponentEditor.cs
- WindowsListViewItem.cs
- ContentPresenter.cs
- Reference.cs
- TokenFactoryFactory.cs
- BigInt.cs
- InputLanguageCollection.cs
- DecoderFallback.cs
- TraceHwndHost.cs
- DefaultBinder.cs
- Expressions.cs
- SerializationObjectManager.cs
- Compilation.cs
- TrackBarRenderer.cs
- counter.cs
- DictionaryContent.cs
- OptimizedTemplateContent.cs
- ScrollEventArgs.cs
- AttributeQuery.cs
- StructuralCache.cs
- SecurityTokenValidationException.cs
- CacheChildrenQuery.cs
- BamlTreeMap.cs
- TokenBasedSet.cs
- VisualBasicReference.cs
- PixelShader.cs
- GifBitmapEncoder.cs
- HandlerWithFactory.cs
- UpdateCompiler.cs
- BaseDataList.cs
- ProxyWebPart.cs
- GeometryGroup.cs
- xmlglyphRunInfo.cs
- VectorConverter.cs
- METAHEADER.cs
- securitycriticaldataformultiplegetandset.cs
- HierarchicalDataBoundControl.cs
- Sentence.cs
- GestureRecognizer.cs
- DrawItemEvent.cs
- WorkItem.cs
- GetRecipientRequest.cs
- AuthenticatingEventArgs.cs
- NamespaceCollection.cs
- TextFormatterContext.cs
- ComplexBindingPropertiesAttribute.cs
- DataGridViewTextBoxEditingControl.cs
- XmlLanguageConverter.cs
- CodeGenerator.cs
- RewritingSimplifier.cs
- XmlIlVisitor.cs
- PermissionRequestEvidence.cs
- MessageQueueEnumerator.cs
- HttpResponseHeader.cs
- DataGridViewTextBoxEditingControl.cs
- EtwTrace.cs
- WebServiceParameterData.cs
- ValidationErrorEventArgs.cs
- TextEffectResolver.cs
- TextRunCacheImp.cs
- CodeSnippetCompileUnit.cs
- HttpListenerPrefixCollection.cs
- KeyEvent.cs
- DynamicResourceExtension.cs
- AccessibleObject.cs
- CertificateManager.cs
- SafeEventHandle.cs