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
- CqlGenerator.cs
- PropertyMapper.cs
- CompilerParameters.cs
- XmlParserContext.cs
- SortQuery.cs
- BitmapEffectDrawingContextWalker.cs
- odbcmetadatacolumnnames.cs
- Int16.cs
- SelectorItemAutomationPeer.cs
- DataGridViewSortCompareEventArgs.cs
- ImageMetadata.cs
- ColorDialog.cs
- RenderData.cs
- ObjectListDesigner.cs
- DesignerTextViewAdapter.cs
- TreeNodeEventArgs.cs
- InvalidTimeZoneException.cs
- DateTimeConverter2.cs
- ControlCollection.cs
- TextRangeEditLists.cs
- SyndicationSerializer.cs
- SqlMethodTransformer.cs
- querybuilder.cs
- PenCursorManager.cs
- CapabilitiesRule.cs
- Control.cs
- SessionStateItemCollection.cs
- Viewport2DVisual3D.cs
- ExceptionValidationRule.cs
- TriggerActionCollection.cs
- PageCatalogPartDesigner.cs
- DbDeleteCommandTree.cs
- TailCallAnalyzer.cs
- ClientSideQueueItem.cs
- UserControl.cs
- TreeNodeCollection.cs
- Native.cs
- Application.cs
- AccessViolationException.cs
- SessionStateModule.cs
- ToggleButtonAutomationPeer.cs
- XPathBuilder.cs
- ComponentDispatcherThread.cs
- AssertFilter.cs
- WebPartCatalogCloseVerb.cs
- ConfigXmlText.cs
- InputLanguageManager.cs
- QueryContinueDragEventArgs.cs
- ObjectCloneHelper.cs
- XmlQualifiedName.cs
- DesignBindingEditor.cs
- SortDescription.cs
- SmiEventStream.cs
- TableLayoutPanel.cs
- ServiceDescriptionSerializer.cs
- ListViewCancelEventArgs.cs
- PolicyException.cs
- PopOutPanel.cs
- NotSupportedException.cs
- IdlingCommunicationPool.cs
- TogglePattern.cs
- odbcmetadatacollectionnames.cs
- WsdlHelpGeneratorElement.cs
- ProtocolsConfiguration.cs
- AmbientLight.cs
- ServiceInstallComponent.cs
- _HeaderInfoTable.cs
- SchemaInfo.cs
- BypassElementCollection.cs
- CaseCqlBlock.cs
- NetworkAddressChange.cs
- PagerSettings.cs
- pingexception.cs
- ValueExpressions.cs
- DetailsViewRow.cs
- ProfilePropertySettings.cs
- UserControlParser.cs
- QilStrConcatenator.cs
- RequestCacheValidator.cs
- SecurityException.cs
- DataTableNewRowEvent.cs
- TextProperties.cs
- ProcessHostFactoryHelper.cs
- OperatingSystem.cs
- XPathMultyIterator.cs
- MaskedTextProvider.cs
- SchemaNames.cs
- SingleAnimationUsingKeyFrames.cs
- SafeBitVector32.cs
- ObservableDictionary.cs
- Menu.cs
- OutputCacheSettingsSection.cs
- CodeSnippetExpression.cs
- PasswordBox.cs
- QueryReaderSettings.cs
- RuntimeIdentifierPropertyAttribute.cs
- ConnectionConsumerAttribute.cs
- Lookup.cs
- Rect3D.cs
- _StreamFramer.cs