Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Internal / Utility / MonitorWrapper.cs / 1 / MonitorWrapper.cs
//---------------------------------------------------------------------------- // //// Copyright (C) 2005 by Microsoft Corporation. All rights reserved. // // // // Description: Wraps System.Threading.Monitor and adds a busy flag // //--------------------------------------------------------------------------- using System; using System.Threading; using System.Windows; using MS.Internal; namespace MS.Internal.Utility { ////// Monitor with Busy flag while it is entered. /// internal class MonitorWrapper { public IDisposable Enter() { Monitor.Enter(_syncRoot); Interlocked.Increment(ref _enterCount); return new MonitorHelper(this); } public void Exit() { int count = Interlocked.Decrement(ref _enterCount); Invariant.Assert(count >= 0, "unmatched call to MonitorWrapper.Exit"); Monitor.Exit(_syncRoot); } public bool Busy { get { return (_enterCount > 0); } } int _enterCount; object _syncRoot = new object(); private class MonitorHelper : IDisposable { public MonitorHelper(MonitorWrapper monitorWrapper) { _monitorWrapper = monitorWrapper; } public void Dispose() { if (_monitorWrapper != null) { _monitorWrapper.Exit(); _monitorWrapper = null; } } private MonitorWrapper _monitorWrapper; } } } // 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
- InvokeProviderWrapper.cs
- CustomAttributeBuilder.cs
- QueryOutputWriterV1.cs
- XmlElementCollection.cs
- CommandField.cs
- CounterSampleCalculator.cs
- Debugger.cs
- CodeAttachEventStatement.cs
- FormViewModeEventArgs.cs
- SaveLedgerEntryRequest.cs
- ClientSideProviderDescription.cs
- TextBoxDesigner.cs
- SystemColors.cs
- TransactionBridge.cs
- TextProperties.cs
- DSACryptoServiceProvider.cs
- HMACSHA512.cs
- HtmlTextViewAdapter.cs
- httpstaticobjectscollection.cs
- ColorContextHelper.cs
- ThicknessAnimation.cs
- ProxyWebPart.cs
- _NTAuthentication.cs
- BindingMemberInfo.cs
- DefaultPrintController.cs
- AlternationConverter.cs
- SHA1Cng.cs
- TemplateControlBuildProvider.cs
- FamilyMapCollection.cs
- SettingsSavedEventArgs.cs
- ToolBar.cs
- StylusPointPropertyId.cs
- ConcurrencyBehavior.cs
- BatchWriter.cs
- PolyQuadraticBezierSegment.cs
- BridgeDataRecord.cs
- Attributes.cs
- SmiEventSink_DeferedProcessing.cs
- IntPtr.cs
- TextUtf8RawTextWriter.cs
- SafeNativeMethods.cs
- KeyPressEvent.cs
- HttpProfileBase.cs
- ValidationEventArgs.cs
- HandlerMappingMemo.cs
- CommandBindingCollection.cs
- ToolStripOverflow.cs
- Atom10FormatterFactory.cs
- Wizard.cs
- CancellationTokenRegistration.cs
- UrlMapping.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- KeyFrames.cs
- WizardDesigner.cs
- CacheMemory.cs
- Wildcard.cs
- MaskedTextBoxTextEditorDropDown.cs
- ExtensionDataObject.cs
- CultureMapper.cs
- WebBrowserNavigatingEventHandler.cs
- Proxy.cs
- DynamicPhysicalDiscoSearcher.cs
- EllipticalNodeOperations.cs
- AuthenticateEventArgs.cs
- Enlistment.cs
- XdrBuilder.cs
- OdbcParameterCollection.cs
- BaseDataBoundControlDesigner.cs
- DataGridViewColumnConverter.cs
- BlockCollection.cs
- CommandExpr.cs
- XmlComplianceUtil.cs
- DynamicPropertyReader.cs
- BinHexEncoding.cs
- SvcMapFileSerializer.cs
- BitmapEditor.cs
- LogStore.cs
- BinaryExpressionHelper.cs
- NodeFunctions.cs
- SqlDataSourceCache.cs
- SoapParser.cs
- ThicknessAnimationBase.cs
- SHA512.cs
- _Rfc2616CacheValidators.cs
- CultureTable.cs
- Profiler.cs
- ViewLoader.cs
- XmlAnyElementAttributes.cs
- _ConnectionGroup.cs
- DataRecordInternal.cs
- PropertyIdentifier.cs
- SchemaContext.cs
- fixedPageContentExtractor.cs
- __Error.cs
- ProgressChangedEventArgs.cs
- DrawingAttributesDefaultValueFactory.cs
- DesignerTransactionCloseEvent.cs
- SiteMapNodeItem.cs
- DataGridItemAutomationPeer.cs
- Switch.cs