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
- TraceUtils.cs
- StreamWithDictionary.cs
- IODescriptionAttribute.cs
- BooleanKeyFrameCollection.cs
- DPTypeDescriptorContext.cs
- FixedFlowMap.cs
- DynamicMethod.cs
- AspNetHostingPermission.cs
- TextTreeDeleteContentUndoUnit.cs
- QuaternionConverter.cs
- MailWebEventProvider.cs
- ChannelSinkStacks.cs
- BinHexDecoder.cs
- UMPAttributes.cs
- UserValidatedEventArgs.cs
- DataTableNameHandler.cs
- autovalidator.cs
- XamlPathDataSerializer.cs
- InternalSafeNativeMethods.cs
- DirectoryInfo.cs
- DiscoveryClientBindingElement.cs
- EmptyQuery.cs
- CompareValidator.cs
- RegexWorker.cs
- ParserExtension.cs
- ConsoleCancelEventArgs.cs
- LazyTextWriterCreator.cs
- SmiEventSink.cs
- mansign.cs
- UserControl.cs
- SubMenuStyleCollection.cs
- DbQueryCommandTree.cs
- XPathSingletonIterator.cs
- GlobalizationSection.cs
- Polygon.cs
- MonthCalendar.cs
- WebContentFormatHelper.cs
- TextBoxAutomationPeer.cs
- DateTimeFormatInfo.cs
- EntitySetDataBindingList.cs
- Freezable.cs
- FuncTypeConverter.cs
- TableParaClient.cs
- XmlNamespaceDeclarationsAttribute.cs
- DocumentApplicationJournalEntry.cs
- TransactionScope.cs
- SqlUserDefinedAggregateAttribute.cs
- RichTextBox.cs
- Focus.cs
- AnonymousIdentificationSection.cs
- SettingsBindableAttribute.cs
- Evidence.cs
- AuthenticationServiceManager.cs
- Fx.cs
- DataKeyPropertyAttribute.cs
- HtmlElementCollection.cs
- VirtualPath.cs
- NTAccount.cs
- ListControl.cs
- TextElement.cs
- Model3D.cs
- WebBrowserContainer.cs
- RuntimeConfig.cs
- CategoryNameCollection.cs
- SQLConvert.cs
- HttpServerVarsCollection.cs
- ConfigurationManagerHelperFactory.cs
- InsufficientExecutionStackException.cs
- ReflectTypeDescriptionProvider.cs
- XPathBinder.cs
- InstanceLockTracking.cs
- MissingManifestResourceException.cs
- ParsedAttributeCollection.cs
- MetadataArtifactLoader.cs
- XamlTemplateSerializer.cs
- SamlSecurityTokenAuthenticator.cs
- TemplateBindingExtensionConverter.cs
- XmlNode.cs
- LongMinMaxAggregationOperator.cs
- ToolStripPanelRow.cs
- DataServiceProcessingPipelineEventArgs.cs
- InstanceDescriptor.cs
- FeatureSupport.cs
- __Filters.cs
- DataGridViewRowsRemovedEventArgs.cs
- InArgumentConverter.cs
- FrameworkContentElement.cs
- ObjectStateEntry.cs
- SchemaTableColumn.cs
- RawAppCommandInputReport.cs
- WebBrowserHelper.cs
- PenContext.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- CheckBox.cs
- XmlTextReaderImpl.cs
- recordstate.cs
- ApplicationDirectoryMembershipCondition.cs
- activationcontext.cs
- UseLicense.cs
- TextSegment.cs