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
- ClientScriptManager.cs
- SoapAttributes.cs
- ParallelTimeline.cs
- Animatable.cs
- InfoCardRSACryptoProvider.cs
- CacheAxisQuery.cs
- XPathNodeHelper.cs
- ConnectivityStatus.cs
- Emitter.cs
- RMPermissions.cs
- ThicknessAnimationUsingKeyFrames.cs
- XmlnsDictionary.cs
- AbsoluteQuery.cs
- ToolStripButton.cs
- VisualTreeHelper.cs
- Shared.cs
- AdapterUtil.cs
- XmlUtil.cs
- SqlClientMetaDataCollectionNames.cs
- SuppressIldasmAttribute.cs
- SafeCancelMibChangeNotify.cs
- ISO2022Encoding.cs
- ConfigurationValidatorBase.cs
- BinaryConverter.cs
- EntitySetDataBindingList.cs
- StrongNameIdentityPermission.cs
- ConstraintCollection.cs
- CommentEmitter.cs
- IntersectQueryOperator.cs
- PeerFlooder.cs
- RectangleHotSpot.cs
- FirstMatchCodeGroup.cs
- QueryParameter.cs
- BlockUIContainer.cs
- UrlAuthorizationModule.cs
- TextSearch.cs
- BitmapSourceSafeMILHandle.cs
- DataGridViewCellStyle.cs
- MultiDataTrigger.cs
- linebase.cs
- SerializationEventsCache.cs
- XamlTreeBuilderBamlRecordWriter.cs
- TwoPhaseCommit.cs
- precedingsibling.cs
- MemberBinding.cs
- Opcode.cs
- MdiWindowListStrip.cs
- AssertSection.cs
- HasCopySemanticsAttribute.cs
- ItemType.cs
- AnnotationMap.cs
- HttpProfileBase.cs
- BufferBuilder.cs
- ProviderConnectionPointCollection.cs
- PassportAuthenticationEventArgs.cs
- RegisteredHiddenField.cs
- SequentialOutput.cs
- PrimitiveCodeDomSerializer.cs
- HtmlInputSubmit.cs
- AtomEntry.cs
- WorkflowDesignerMessageFilter.cs
- CaseCqlBlock.cs
- LicenseException.cs
- ReachDocumentReferenceCollectionSerializerAsync.cs
- GridProviderWrapper.cs
- LinkLabelLinkClickedEvent.cs
- XhtmlBasicPageAdapter.cs
- SqlNodeTypeOperators.cs
- ApplicationBuildProvider.cs
- CookielessHelper.cs
- DrawingGroupDrawingContext.cs
- EdmSchemaError.cs
- DataRowCollection.cs
- MultiSelectRootGridEntry.cs
- Deflater.cs
- IIS7WorkerRequest.cs
- SkinBuilder.cs
- DecimalConstantAttribute.cs
- WebConfigurationManager.cs
- XmlSchemaParticle.cs
- EdmFunction.cs
- XmlC14NWriter.cs
- PageClientProxyGenerator.cs
- Graph.cs
- ParserStreamGeometryContext.cs
- SchemaContext.cs
- WebPartUtil.cs
- PersonalizationProviderHelper.cs
- ExtenderProvidedPropertyAttribute.cs
- Padding.cs
- sitestring.cs
- SourceElementsCollection.cs
- MembershipSection.cs
- ResolveCompletedEventArgs.cs
- BaseValidator.cs
- AssemblySettingAttributes.cs
- SystemTcpConnection.cs
- WriteableBitmap.cs
- MD5CryptoServiceProvider.cs
- PageEventArgs.cs