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
- ControlDesigner.cs
- HierarchicalDataBoundControl.cs
- DbConnectionClosed.cs
- HwndSource.cs
- TypeResolvingOptionsAttribute.cs
- PkcsUtils.cs
- TagNameToTypeMapper.cs
- SafeNativeMethods.cs
- ParameterElementCollection.cs
- LinqDataSourceHelper.cs
- XPSSignatureDefinition.cs
- AnonymousIdentificationSection.cs
- DbProviderFactory.cs
- ErrorHandler.cs
- ParenthesizePropertyNameAttribute.cs
- DPTypeDescriptorContext.cs
- PathStreamGeometryContext.cs
- Menu.cs
- Types.cs
- TranslateTransform.cs
- WindowsUpDown.cs
- DiscreteKeyFrames.cs
- TemplateInstanceAttribute.cs
- QueryContinueDragEventArgs.cs
- OverflowException.cs
- webclient.cs
- StaticExtension.cs
- WebBodyFormatMessageProperty.cs
- ExternalCalls.cs
- PathSegment.cs
- DataGridViewCheckBoxColumn.cs
- SelectionPattern.cs
- CommonGetThemePartSize.cs
- BitStream.cs
- StandardBindingOptionalReliableSessionElement.cs
- SqlReferenceCollection.cs
- DmlSqlGenerator.cs
- PrePrepareMethodAttribute.cs
- UriScheme.cs
- DynamicDataResources.Designer.cs
- NativeCppClassAttribute.cs
- VirtualPathData.cs
- CharacterBufferReference.cs
- ElapsedEventArgs.cs
- InkCanvasInnerCanvas.cs
- OraclePermission.cs
- XsltCompileContext.cs
- EventLogException.cs
- WebPartEditVerb.cs
- GenericEnumerator.cs
- EncodingNLS.cs
- DataGridTextBoxColumn.cs
- DesignerRegionCollection.cs
- CssClassPropertyAttribute.cs
- DefaultParameterValueAttribute.cs
- MailWriter.cs
- TextCompositionEventArgs.cs
- WebBrowserProgressChangedEventHandler.cs
- SettingsPropertyWrongTypeException.cs
- AudioStateChangedEventArgs.cs
- RestHandler.cs
- OrderedDictionaryStateHelper.cs
- DecimalAnimationUsingKeyFrames.cs
- PointUtil.cs
- AlphaSortedEnumConverter.cs
- ProfilePropertySettingsCollection.cs
- ContainerUtilities.cs
- ExecutedRoutedEventArgs.cs
- UpdateManifestForBrowserApplication.cs
- Size3D.cs
- AppDomainShutdownMonitor.cs
- PenThreadWorker.cs
- TraceListeners.cs
- Regex.cs
- RadioButtonDesigner.cs
- ToolStripLocationCancelEventArgs.cs
- SqlDataSourceEnumerator.cs
- RawMouseInputReport.cs
- WebPartDescription.cs
- DoubleAnimationUsingPath.cs
- EncoderFallback.cs
- TypeBuilderInstantiation.cs
- RenderDataDrawingContext.cs
- PropertyPath.cs
- SchemaTableOptionalColumn.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- DeadCharTextComposition.cs
- EmptyReadOnlyDictionaryInternal.cs
- ParenthesizePropertyNameAttribute.cs
- ToolStripDropDown.cs
- Pointer.cs
- SupportsPreviewControlAttribute.cs
- LexicalChunk.cs
- X509Certificate2.cs
- WebPartHeaderCloseVerb.cs
- FixedTextContainer.cs
- GZipDecoder.cs
- RawStylusSystemGestureInputReport.cs
- WebPartUserCapability.cs
- HtmlUtf8RawTextWriter.cs