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
- MsmqInputMessage.cs
- StdValidatorsAndConverters.cs
- ParseNumbers.cs
- ProcessHostMapPath.cs
- HWStack.cs
- NotifyInputEventArgs.cs
- WSSecurityXXX2005.cs
- RegexWorker.cs
- GridViewRowCollection.cs
- LoadedEvent.cs
- ConstraintStruct.cs
- XPathParser.cs
- __Error.cs
- UrlPropertyAttribute.cs
- SuppressMergeCheckAttribute.cs
- AssemblyBuilderData.cs
- ReversePositionQuery.cs
- SetIndexBinder.cs
- HyperLinkField.cs
- ResXBuildProvider.cs
- ToolboxDataAttribute.cs
- WpfMemberInvoker.cs
- GlobalizationAssembly.cs
- Journal.cs
- StaticFileHandler.cs
- AssemblyAttributes.cs
- ClientConfigurationSystem.cs
- DataGridViewRowConverter.cs
- DataBinding.cs
- SqlDataSourceWizardForm.cs
- TraceLevelStore.cs
- DataGridAutomationPeer.cs
- WrappedDispatcherException.cs
- SchemaElement.cs
- MediaCommands.cs
- XmlElementList.cs
- RemoteArgument.cs
- ISAPIApplicationHost.cs
- StateItem.cs
- MSAANativeProvider.cs
- IPAddressCollection.cs
- XsdCachingReader.cs
- RichTextBoxAutomationPeer.cs
- GlobalAllocSafeHandle.cs
- UserControlBuildProvider.cs
- EventMetadata.cs
- TextDecorationCollectionConverter.cs
- CompressionTransform.cs
- WebPartDisplayModeEventArgs.cs
- IsolatedStorageSecurityState.cs
- ToolBar.cs
- DbConnectionPoolGroupProviderInfo.cs
- QilList.cs
- RowsCopiedEventArgs.cs
- RealizationDrawingContextWalker.cs
- NonVisualControlAttribute.cs
- TimerEventSubscriptionCollection.cs
- ProxyElement.cs
- Socket.cs
- TransformerTypeCollection.cs
- WebServiceTypeData.cs
- TransactionScope.cs
- LoginUtil.cs
- SyntaxCheck.cs
- BitStack.cs
- AttachmentCollection.cs
- GatewayDefinition.cs
- ByeMessageCD1.cs
- ParsedAttributeCollection.cs
- SmiGettersStream.cs
- PageClientProxyGenerator.cs
- Literal.cs
- AudioLevelUpdatedEventArgs.cs
- DataListItem.cs
- Calendar.cs
- DiscoveryReference.cs
- EdmComplexTypeAttribute.cs
- StreamWithDictionary.cs
- StrongNamePublicKeyBlob.cs
- CodeRegionDirective.cs
- ClearCollection.cs
- FrameworkRichTextComposition.cs
- SqlStatistics.cs
- SemanticResultValue.cs
- XpsSerializationException.cs
- LinqDataSourceUpdateEventArgs.cs
- TraceUtils.cs
- AutoResetEvent.cs
- COM2EnumConverter.cs
- InputReportEventArgs.cs
- ScriptRegistrationManager.cs
- DbMetaDataCollectionNames.cs
- EditorZone.cs
- BaseTemplateCodeDomTreeGenerator.cs
- InvokePattern.cs
- TextRangeEdit.cs
- HtmlTextBoxAdapter.cs
- JsonReader.cs
- SchemaImporterExtension.cs
- GPStream.cs