Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Shared / MS / Internal / ReaderWriterLockWrapper.cs / 1 / ReaderWriterLockWrapper.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: // Wrapper that allows a ReaderWriterLock to work with C#'s using() clause // // History: // 07/23/2003 : [....] Ported to WCP // //--------------------------------------------------------------------------- using System; using System.Threading; using MS.Internal.WindowsBase; namespace MS.Internal { // Wrapper that allows a ReaderWriterLock to work with C#'s using() clause [FriendAccessAllowed] // Built into Base, used by Core and Framework. internal class ReaderWriterLockWrapper { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors internal ReaderWriterLockWrapper() { _rwLock = new ReaderWriterLock(); _awr = new AutoWriterRelease(_rwLock); _arr = new AutoReaderRelease(_rwLock); } #endregion Constructors //------------------------------------------------------ // // Internal Properties // //----------------------------------------------------- #region Internal Properties internal IDisposable WriteLock { get { _rwLock.AcquireWriterLock(Timeout.Infinite); return _awr; } } internal IDisposable ReadLock { get { _rwLock.AcquireReaderLock(Timeout.Infinite); return _arr; } } #endregion Internal Properties //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields private ReaderWriterLock _rwLock; private AutoReaderRelease _arr; private AutoWriterRelease _awr; #endregion Private Fields //----------------------------------------------------- // // Private Classes & Structs // //------------------------------------------------------ #region Private Classes & Structs private struct AutoWriterRelease : IDisposable { public AutoWriterRelease(ReaderWriterLock rwLock) { _lock = rwLock; } public void Dispose() { _lock.ReleaseWriterLock(); } private ReaderWriterLock _lock; } private struct AutoReaderRelease : IDisposable { public AutoReaderRelease(ReaderWriterLock rwLock) { _lock = rwLock; } public void Dispose() { _lock.ReleaseReaderLock(); } private ReaderWriterLock _lock; } #endregion Private Classes } } // 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
- _Connection.cs
- MembershipUser.cs
- AlignmentXValidation.cs
- VirtualPathUtility.cs
- XmlEntityReference.cs
- SqlDeflator.cs
- SerializationObjectManager.cs
- SiteMap.cs
- DetailsViewUpdatedEventArgs.cs
- AxHost.cs
- CodeSubDirectoriesCollection.cs
- AutoGeneratedFieldProperties.cs
- XamlSerializerUtil.cs
- CannotUnloadAppDomainException.cs
- SelectionProviderWrapper.cs
- ScrollViewerAutomationPeer.cs
- SplitterPanel.cs
- PreProcessInputEventArgs.cs
- ContentType.cs
- AppDomainAttributes.cs
- ProfilePropertySettingsCollection.cs
- NameObjectCollectionBase.cs
- StateDesigner.CommentLayoutGlyph.cs
- MemberDescriptor.cs
- CompatibleIComparer.cs
- cookiecollection.cs
- EmbeddedMailObject.cs
- CodeDOMProvider.cs
- XmlSchemaProviderAttribute.cs
- ApplicationFileCodeDomTreeGenerator.cs
- DynamicFilterExpression.cs
- XpsLiterals.cs
- HostingEnvironmentWrapper.cs
- InsufficientExecutionStackException.cs
- AttachmentService.cs
- StorageComplexTypeMapping.cs
- MethodCallConverter.cs
- ServiceDescriptionReflector.cs
- FragmentQueryProcessor.cs
- OleDbConnectionFactory.cs
- ImageSourceValueSerializer.cs
- CodeObject.cs
- SerialErrors.cs
- PartialList.cs
- Path.cs
- SqlDataSourceCache.cs
- PathSegment.cs
- SQLGuid.cs
- DiffuseMaterial.cs
- ReadOnlyAttribute.cs
- Bits.cs
- ParserStack.cs
- AdapterDictionary.cs
- BindingSourceDesigner.cs
- TextBoxRenderer.cs
- StylusEventArgs.cs
- TimeSpan.cs
- X509Utils.cs
- PTProvider.cs
- StreamInfo.cs
- PublishLicense.cs
- TagMapInfo.cs
- OleDbErrorCollection.cs
- StylusPointDescription.cs
- TraversalRequest.cs
- CustomPopupPlacement.cs
- DeviceOverridableAttribute.cs
- ExternalFile.cs
- DocumentEventArgs.cs
- CngUIPolicy.cs
- ToolTipAutomationPeer.cs
- XsltInput.cs
- FrugalList.cs
- SecurityState.cs
- InvalidateEvent.cs
- View.cs
- WebSysDescriptionAttribute.cs
- StoreAnnotationsMap.cs
- MailAddressCollection.cs
- Validator.cs
- ToolStripPanelCell.cs
- PropertyDescriptorComparer.cs
- TdsParser.cs
- HttpContext.cs
- Page.cs
- EventWaitHandleSecurity.cs
- FixedPageAutomationPeer.cs
- GrammarBuilderWildcard.cs
- CodeTypeMemberCollection.cs
- OneOfScalarConst.cs
- PropertyBuilder.cs
- BindingNavigator.cs
- DetailsView.cs
- CmsInterop.cs
- DescendentsWalkerBase.cs
- Control.cs
- GcHandle.cs
- ProviderException.cs
- DeleteHelper.cs
- UiaCoreApi.cs