Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- AnnotationResourceChangedEventArgs.cs
- ManagedCodeMarkers.cs
- DbTransaction.cs
- MenuScrollingVisibilityConverter.cs
- Focus.cs
- Walker.cs
- SafeNativeMethods.cs
- NativeActivityTransactionContext.cs
- MessageSecurityOverMsmqElement.cs
- ListView.cs
- ConfigsHelper.cs
- SortedDictionary.cs
- BitmapInitialize.cs
- ActiveXHelper.cs
- DataContext.cs
- GroupBoxRenderer.cs
- OleDbConnection.cs
- ContainerParaClient.cs
- WindowsComboBox.cs
- OLEDB_Util.cs
- ValueTypeFixupInfo.cs
- WebPartMenuStyle.cs
- KeyedByTypeCollection.cs
- HtmlInputReset.cs
- EntityUtil.cs
- CTreeGenerator.cs
- TableColumn.cs
- EntityModelBuildProvider.cs
- WorkflowDesigner.cs
- OptimalBreakSession.cs
- TextBlock.cs
- DecimalConverter.cs
- SimpleApplicationHost.cs
- DocumentPage.cs
- HttpContextBase.cs
- EntityCommand.cs
- CollectionConverter.cs
- AmbiguousMatchException.cs
- HttpAsyncResult.cs
- ISO2022Encoding.cs
- LockedBorderGlyph.cs
- ProxyWebPartConnectionCollection.cs
- DataBoundControlAdapter.cs
- ConsoleCancelEventArgs.cs
- ValidationRule.cs
- ConnectionPoint.cs
- NavigationFailedEventArgs.cs
- DataRecordInternal.cs
- AttachedAnnotationChangedEventArgs.cs
- ListItemParagraph.cs
- WhereQueryOperator.cs
- BulletDecorator.cs
- XhtmlBasicObjectListAdapter.cs
- SocketCache.cs
- LayoutUtils.cs
- SqlProviderManifest.cs
- ListViewGroup.cs
- listviewsubitemcollectioneditor.cs
- PersistenceTypeAttribute.cs
- StatusBarPanel.cs
- DataGridPreparingCellForEditEventArgs.cs
- HttpCacheParams.cs
- TextServicesManager.cs
- DynamicDocumentPaginator.cs
- PeerMessageDispatcher.cs
- unsafenativemethodsother.cs
- XmlDataLoader.cs
- CapabilitiesUse.cs
- InputQueue.cs
- LateBoundChannelParameterCollection.cs
- FirstMatchCodeGroup.cs
- SchemaElementLookUpTable.cs
- GridToolTip.cs
- AnonymousIdentificationModule.cs
- SoapClientProtocol.cs
- TypeValidationEventArgs.cs
- WebPartConnectionsDisconnectVerb.cs
- ComplexTypeEmitter.cs
- UnitySerializationHolder.cs
- SpecularMaterial.cs
- SafeWaitHandle.cs
- Animatable.cs
- FragmentQueryProcessor.cs
- ParserContext.cs
- StringStorage.cs
- UnwrappedTypesXmlSerializerManager.cs
- GeneralTransform3DTo2D.cs
- Application.cs
- FileRecordSequenceCompletedAsyncResult.cs
- serverconfig.cs
- StylesEditorDialog.cs
- DataGridViewCellStyleBuilderDialog.cs
- Matrix.cs
- ReliableChannelFactory.cs
- SolidBrush.cs
- PointAnimationUsingKeyFrames.cs
- LongValidatorAttribute.cs
- BrowserTree.cs
- FixedPage.cs
- ScrollData.cs