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
- ParameterCollection.cs
- BamlRecordWriter.cs
- CharacterBuffer.cs
- DataControlFieldCollection.cs
- DashStyles.cs
- ConnectionStringsExpressionEditor.cs
- ProxySimple.cs
- XmlUnspecifiedAttribute.cs
- XsdDateTime.cs
- XmlSchemaValidationException.cs
- PassportPrincipal.cs
- OracleBoolean.cs
- BitmapCodecInfoInternal.cs
- UInt16Converter.cs
- SqlResolver.cs
- CodeObject.cs
- DWriteFactory.cs
- TaiwanLunisolarCalendar.cs
- ListManagerBindingsCollection.cs
- OdbcTransaction.cs
- ValidationManager.cs
- MemberInfoSerializationHolder.cs
- ExpandCollapsePattern.cs
- DependencyProperty.cs
- DocumentCollection.cs
- DoubleAnimationBase.cs
- CacheForPrimitiveTypes.cs
- KerberosTokenFactoryCredential.cs
- TransformerTypeCollection.cs
- FrameworkElementFactory.cs
- MultitargetUtil.cs
- SrgsDocument.cs
- DbCommandDefinition.cs
- GeneralTransform3D.cs
- PinnedBufferMemoryStream.cs
- MarkupCompilePass2.cs
- LinearKeyFrames.cs
- ProfileSection.cs
- ImageListStreamer.cs
- GridViewRowPresenterBase.cs
- TextureBrush.cs
- Ports.cs
- DataGridItemEventArgs.cs
- ChangesetResponse.cs
- SoapException.cs
- TemplateControl.cs
- SendKeys.cs
- SystemIcons.cs
- Control.cs
- MethodBody.cs
- Soap12ProtocolReflector.cs
- HeaderFilter.cs
- SystemIPv6InterfaceProperties.cs
- RemoteWebConfigurationHostStream.cs
- ConfigurationValidatorAttribute.cs
- HMACSHA1.cs
- ObjectNavigationPropertyMapping.cs
- ClusterRegistryConfigurationProvider.cs
- EventManager.cs
- WebPartAddingEventArgs.cs
- ImplicitInputBrush.cs
- Events.cs
- DataRowExtensions.cs
- PathFigureCollection.cs
- WebPartHeaderCloseVerb.cs
- CommandHelpers.cs
- DbDataAdapter.cs
- CheckBoxBaseAdapter.cs
- DataControlFieldHeaderCell.cs
- ColumnTypeConverter.cs
- DBDataPermissionAttribute.cs
- MexBindingElement.cs
- VisualStyleInformation.cs
- CapabilitiesPattern.cs
- CommunicationException.cs
- WindowsStreamSecurityBindingElement.cs
- LayoutInformation.cs
- DetailsViewPagerRow.cs
- StylusPoint.cs
- ToolStripDropDownItem.cs
- Misc.cs
- StdValidatorsAndConverters.cs
- LinqDataSourceSelectEventArgs.cs
- DockProviderWrapper.cs
- UncommonField.cs
- MD5Cng.cs
- MatrixTransform3D.cs
- SqlSupersetValidator.cs
- UIElementHelper.cs
- UIHelper.cs
- DataGridParentRows.cs
- ClientSession.cs
- SerialReceived.cs
- ContentIterators.cs
- ResourceAssociationType.cs
- METAHEADER.cs
- CodeGroup.cs
- StaticSiteMapProvider.cs
- EncoderBestFitFallback.cs
- Array.cs