Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Internal / ReaderWriterLockWrapper.cs / 1305600 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StyleSelector.cs
- controlskin.cs
- StandardBindingOptionalReliableSessionElement.cs
- xml.cs
- DbModificationClause.cs
- UnsafeNativeMethodsTablet.cs
- Transactions.cs
- HMAC.cs
- ActivityInfo.cs
- DataGridViewRowCancelEventArgs.cs
- ItemsChangedEventArgs.cs
- EntityDataSourceSelectedEventArgs.cs
- SqlParameter.cs
- IPHostEntry.cs
- WindowsTab.cs
- DirectionalLight.cs
- StreamGeometry.cs
- Permission.cs
- RefreshPropertiesAttribute.cs
- WebReferenceCollection.cs
- PerformanceCounterPermissionAttribute.cs
- ModelTreeManager.cs
- _DisconnectOverlappedAsyncResult.cs
- IOThreadTimer.cs
- DataGridViewCellEventArgs.cs
- BaseTemplateCodeDomTreeGenerator.cs
- ColorContextHelper.cs
- ConfigurationLocation.cs
- HashCodeCombiner.cs
- UnmanagedBitmapWrapper.cs
- Int32RectValueSerializer.cs
- DbResourceAllocator.cs
- SafeArrayRankMismatchException.cs
- PointAnimationUsingKeyFrames.cs
- Rule.cs
- ServiceProviders.cs
- panel.cs
- ColorAnimationUsingKeyFrames.cs
- XsltOutput.cs
- ResolveResponseInfo.cs
- PasswordTextNavigator.cs
- DataGridViewCellPaintingEventArgs.cs
- LocalFileSettingsProvider.cs
- ReturnValue.cs
- LassoSelectionBehavior.cs
- Int64Converter.cs
- InvalidComObjectException.cs
- ResourceDictionaryCollection.cs
- SqlDelegatedTransaction.cs
- DataSourceHelper.cs
- ToolBar.cs
- FlatButtonAppearance.cs
- CustomSignedXml.cs
- JsonFormatWriterGenerator.cs
- UInt32.cs
- WebPartDescription.cs
- CellPartitioner.cs
- RemoteTokenFactory.cs
- XmlFormatExtensionPrefixAttribute.cs
- HwndSourceParameters.cs
- PeerApplicationLaunchInfo.cs
- PageContent.cs
- UpDownEvent.cs
- ConfigXmlText.cs
- ConfigurationManagerHelperFactory.cs
- DelegateSerializationHolder.cs
- UrlUtility.cs
- SocketInformation.cs
- PolicyStatement.cs
- ScopelessEnumAttribute.cs
- PersistChildrenAttribute.cs
- BuildManager.cs
- XmlSchemaSimpleTypeList.cs
- MessageQueueKey.cs
- ColorInterpolationModeValidation.cs
- ImagingCache.cs
- ProviderConnectionPoint.cs
- QilParameter.cs
- RemoteWebConfigurationHostStream.cs
- PrivacyNoticeElement.cs
- CompModHelpers.cs
- XmlSchemaComplexType.cs
- PerformanceCounterCategory.cs
- Listbox.cs
- RegexMatchCollection.cs
- TextEditorCopyPaste.cs
- OracleColumn.cs
- CurrencyWrapper.cs
- WmlObjectListAdapter.cs
- SourceElementsCollection.cs
- ComPersistableTypeElementCollection.cs
- TextSelectionProcessor.cs
- ControlDesigner.cs
- WebServiceClientProxyGenerator.cs
- DropShadowEffect.cs
- HttpContextServiceHost.cs
- DataKeyCollection.cs
- SmtpClient.cs
- ControlPaint.cs
- PrtTicket_Public.cs