Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / PtsHost / UnmanagedHandle.cs / 1305600 / 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 : [....] - 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; } GC.SuppressFinalize(this); } ////// 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 : [....] - 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; } GC.SuppressFinalize(this); } ////// 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
- ErrorStyle.cs
- WebPartCollection.cs
- FixedTextSelectionProcessor.cs
- AtomEntry.cs
- HtmlInputSubmit.cs
- TheQuery.cs
- CounterNameConverter.cs
- StagingAreaInputItem.cs
- DataList.cs
- SafeNativeMethods.cs
- BindValidator.cs
- ReadOnlyNameValueCollection.cs
- BaseParaClient.cs
- ProfessionalColors.cs
- ServiceOperationViewControl.cs
- Baml2006KeyRecord.cs
- ControlParameter.cs
- SafeBitVector32.cs
- ComponentRenameEvent.cs
- DataGridViewCellFormattingEventArgs.cs
- ReadOnlyNameValueCollection.cs
- QueryOutputWriter.cs
- GridViewColumn.cs
- ListViewUpdatedEventArgs.cs
- ActivityExecutionContext.cs
- GridViewRow.cs
- SiteMapPath.cs
- ConfigWriter.cs
- PathSegment.cs
- DoubleLinkListEnumerator.cs
- TemplateApplicationHelper.cs
- ThemeDirectoryCompiler.cs
- DataGridViewCellParsingEventArgs.cs
- OperandQuery.cs
- ProjectedWrapper.cs
- SessionState.cs
- KeySpline.cs
- CounterSetInstanceCounterDataSet.cs
- TextSpanModifier.cs
- CommandValueSerializer.cs
- _ShellExpression.cs
- Speller.cs
- OleDbParameterCollection.cs
- SurrogateEncoder.cs
- SubqueryRules.cs
- Viewport3DVisual.cs
- MouseDevice.cs
- CallContext.cs
- ExtendedPropertiesHandler.cs
- DelegateBodyWriter.cs
- GifBitmapDecoder.cs
- HostExecutionContextManager.cs
- WeakReadOnlyCollection.cs
- Propagator.cs
- MessageSmuggler.cs
- FlatButtonAppearance.cs
- TabControlDesigner.cs
- WorkItem.cs
- PanelStyle.cs
- DbCommandTree.cs
- HtmlControlPersistable.cs
- Int64Storage.cs
- FormViewInsertEventArgs.cs
- RIPEMD160Managed.cs
- XmlConvert.cs
- SecurityKeyIdentifierClause.cs
- ConfigurationElement.cs
- InvalidProgramException.cs
- PTProvider.cs
- ResolveMatchesCD1.cs
- OperationPerformanceCounters.cs
- TextParaLineResult.cs
- DrawingContextWalker.cs
- ApplySecurityAndSendAsyncResult.cs
- IDQuery.cs
- XamlReader.cs
- Material.cs
- FontWeightConverter.cs
- AutomationPatternInfo.cs
- TreeNodeCollection.cs
- PasswordTextContainer.cs
- FusionWrap.cs
- TargetInvocationException.cs
- MessageHeaderDescription.cs
- IPPacketInformation.cs
- TextEditorTyping.cs
- SelectionEditor.cs
- SemanticResolver.cs
- ProcessHostServerConfig.cs
- BindUriHelper.cs
- DBCSCodePageEncoding.cs
- HttpChannelHelpers.cs
- UnmanagedMarshal.cs
- XmlAttributes.cs
- ScalarOps.cs
- SQLBytesStorage.cs
- CachingHintValidation.cs
- RequestCacheManager.cs
- ObjectDataSourceMethodEventArgs.cs
- ImageListImage.cs