Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / 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 : BrendanM 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. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: // Wrapper that allows a ReaderWriterLock to work with C#'s using() clause // // History: // 07/23/2003 : BrendanM 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
- CallTemplateAction.cs
- XmlUTF8TextReader.cs
- ArrangedElement.cs
- AutoCompleteStringCollection.cs
- FrameworkReadOnlyPropertyMetadata.cs
- Int16KeyFrameCollection.cs
- DesignerView.Commands.cs
- ReversePositionQuery.cs
- Size3D.cs
- CounterNameConverter.cs
- SystemMulticastIPAddressInformation.cs
- ViewSimplifier.cs
- LabelEditEvent.cs
- ExceptionUtil.cs
- sitestring.cs
- Effect.cs
- DependencyPropertyDescriptor.cs
- DataGridHelper.cs
- IncrementalCompileAnalyzer.cs
- OdbcDataAdapter.cs
- ProfileManager.cs
- SafeTimerHandle.cs
- DataGridSortCommandEventArgs.cs
- RemotingConfigParser.cs
- ReadOnlyCollectionBase.cs
- SQLString.cs
- ObjectDataSourceWizardForm.cs
- __TransparentProxy.cs
- BeginEvent.cs
- FormViewUpdatedEventArgs.cs
- VisualStyleElement.cs
- XmlQualifiedName.cs
- SocketException.cs
- CommonXSendMessage.cs
- OwnerDrawPropertyBag.cs
- TextTreeTextElementNode.cs
- SoapClientMessage.cs
- Line.cs
- ViewStateModeByIdAttribute.cs
- Brushes.cs
- ILGen.cs
- SecurityTokenProvider.cs
- ASCIIEncoding.cs
- XmlNodeChangedEventManager.cs
- ConfigurationManagerInternalFactory.cs
- TabControlAutomationPeer.cs
- SettingsPropertyValueCollection.cs
- SelectionGlyphBase.cs
- ModuleBuilderData.cs
- ControlUtil.cs
- ExpressionList.cs
- CodeIdentifiers.cs
- ColorInterpolationModeValidation.cs
- xml.cs
- CacheHelper.cs
- TextFindEngine.cs
- CodeTypeParameter.cs
- CommentGlyph.cs
- ReceiveMessageRecord.cs
- DebugHandleTracker.cs
- TreeViewAutomationPeer.cs
- WebPartEditorCancelVerb.cs
- MeshGeometry3D.cs
- HttpWebRequestElement.cs
- EventLogPermissionEntry.cs
- UnsafeNativeMethods.cs
- XmlRawWriter.cs
- XpsS0ValidatingLoader.cs
- StackOverflowException.cs
- TextElement.cs
- InteropExecutor.cs
- ImageDrawing.cs
- RequestCacheEntry.cs
- CaseCqlBlock.cs
- UnSafeCharBuffer.cs
- CacheMemory.cs
- RsaSecurityToken.cs
- AVElementHelper.cs
- Pointer.cs
- CorrelationKey.cs
- arabicshape.cs
- Converter.cs
- DictionaryManager.cs
- FixedHyperLink.cs
- SizeAnimation.cs
- PositiveTimeSpanValidatorAttribute.cs
- RenderData.cs
- MessageQueuePermission.cs
- EntitySqlQueryCacheEntry.cs
- GregorianCalendar.cs
- DataGridTablesFactory.cs
- PathData.cs
- MimeBasePart.cs
- UInt32Storage.cs
- RegistryPermission.cs
- ThreadExceptionDialog.cs
- Trace.cs
- ColorTransformHelper.cs
- SubpageParaClient.cs
- EpmTargetTree.cs