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
- EncoderParameters.cs
- EditingCommands.cs
- ReadOnlyDataSource.cs
- SerialReceived.cs
- XmlAnyElementAttributes.cs
- UnsafeNativeMethodsTablet.cs
- CodeSnippetStatement.cs
- FixedSOMGroup.cs
- InnerItemCollectionView.cs
- CommandBindingCollection.cs
- HashHelper.cs
- SqlServer2KCompatibilityCheck.cs
- ContextMenuStripGroup.cs
- HttpRuntime.cs
- Lease.cs
- DataSysAttribute.cs
- _AutoWebProxyScriptWrapper.cs
- DataGridDesigner.cs
- SettingsPropertyIsReadOnlyException.cs
- CodeConstructor.cs
- MonthChangedEventArgs.cs
- CalloutQueueItem.cs
- DataGridViewCellStyleChangedEventArgs.cs
- XslCompiledTransform.cs
- DTCTransactionManager.cs
- MessageProtectionOrder.cs
- SequenceDesigner.cs
- Vector3DCollectionConverter.cs
- DocumentScope.cs
- BaseTemplateBuildProvider.cs
- ResXResourceSet.cs
- DiscoveryClientChannelFactory.cs
- ColorInterpolationModeValidation.cs
- Label.cs
- FixedSOMSemanticBox.cs
- EntityDataSourceContextDisposingEventArgs.cs
- HostedHttpContext.cs
- MsmqMessageProperty.cs
- SoapReflectionImporter.cs
- DesignerSerializationVisibilityAttribute.cs
- DataListCommandEventArgs.cs
- DelegateSerializationHolder.cs
- AutomationTextAttribute.cs
- StoryFragments.cs
- InputReferenceExpression.cs
- ChtmlMobileTextWriter.cs
- AnimationClock.cs
- MouseEvent.cs
- WsatServiceCertificate.cs
- CalculatedColumn.cs
- ModelTreeManager.cs
- EntityFunctions.cs
- SchemaAttDef.cs
- PasswordBoxAutomationPeer.cs
- GenericWebPart.cs
- ReachDocumentPageSerializerAsync.cs
- Mouse.cs
- HandleCollector.cs
- Italic.cs
- SourceCollection.cs
- FormatterServices.cs
- _OSSOCK.cs
- StoreItemCollection.Loader.cs
- StringTraceRecord.cs
- WorkflowMessageEventArgs.cs
- MimePart.cs
- embossbitmapeffect.cs
- SmtpDigestAuthenticationModule.cs
- DoubleConverter.cs
- SelectionListComponentEditor.cs
- StackOverflowException.cs
- PropertyChangingEventArgs.cs
- TrustSection.cs
- SelectionItemProviderWrapper.cs
- InputBinding.cs
- StringSource.cs
- SQLBytes.cs
- EventPrivateKey.cs
- GridViewDeletedEventArgs.cs
- SecurityBindingElementImporter.cs
- DataGridViewTextBoxColumn.cs
- DataGridPagerStyle.cs
- DropDownButton.cs
- FileSecurity.cs
- StyleSheetDesigner.cs
- InstanceContext.cs
- IntMinMaxAggregationOperator.cs
- XDRSchema.cs
- Part.cs
- SafeNativeMethodsMilCoreApi.cs
- HttpApplicationFactory.cs
- ListControlBuilder.cs
- RepeaterItemCollection.cs
- DeclarativeCatalogPart.cs
- HandlerBase.cs
- GridViewCancelEditEventArgs.cs
- PropertyPath.cs
- SqlConnectionPoolProviderInfo.cs
- ResourceExpressionBuilder.cs
- DispatchChannelSink.cs