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
- FormsAuthenticationConfiguration.cs
- UriExt.cs
- RangeValidator.cs
- IgnorePropertiesAttribute.cs
- BitmapEffectGeneralTransform.cs
- _AuthenticationState.cs
- CodeVariableReferenceExpression.cs
- SqlCommandBuilder.cs
- Site.cs
- DummyDataSource.cs
- FrugalList.cs
- FacetEnabledSchemaElement.cs
- ExpanderAutomationPeer.cs
- ViewGenResults.cs
- LabelDesigner.cs
- UInt64Converter.cs
- BeginStoryboard.cs
- baseaxisquery.cs
- dataSvcMapFileLoader.cs
- ConfigurationException.cs
- Expr.cs
- EmptyImpersonationContext.cs
- Scheduling.cs
- ReadOnlyAttribute.cs
- WebEventCodes.cs
- CollectionViewGroupInternal.cs
- NullToBooleanConverter.cs
- WebPartConnectionsConfigureVerb.cs
- ValidatedControlConverter.cs
- CodeGenerator.cs
- SingleAnimationBase.cs
- PageHandlerFactory.cs
- UDPClient.cs
- RelOps.cs
- EventRoute.cs
- XmlSchemaCompilationSettings.cs
- DeclarativeCatalogPart.cs
- RbTree.cs
- InvalidPrinterException.cs
- HijriCalendar.cs
- FontDialog.cs
- SessionParameter.cs
- StorageMappingFragment.cs
- ResourceReader.cs
- ManagementScope.cs
- LongTypeConverter.cs
- SharedPersonalizationStateInfo.cs
- CqlBlock.cs
- WebPartHelpVerb.cs
- Fonts.cs
- ExpressionTextBoxAutomationPeer.cs
- Utility.cs
- CellNormalizer.cs
- XmlSchema.cs
- XslTransform.cs
- MailDefinition.cs
- PackageRelationshipSelector.cs
- WebPartDisplayModeCancelEventArgs.cs
- XmlBindingWorker.cs
- PartialCachingControl.cs
- FixedSOMElement.cs
- DataGridViewCellLinkedList.cs
- TransformerInfoCollection.cs
- TextProperties.cs
- FileChangesMonitor.cs
- HandleRef.cs
- XmlSchemaInfo.cs
- FixUpCollection.cs
- TreeBuilder.cs
- Opcode.cs
- PropertyInformationCollection.cs
- Control.cs
- XmlNodeReader.cs
- RangeBase.cs
- AccessibleObject.cs
- basemetadatamappingvisitor.cs
- CodeConditionStatement.cs
- InternalsVisibleToAttribute.cs
- DetailsViewInsertedEventArgs.cs
- SafeHGlobalHandleCritical.cs
- InvokeHandlers.cs
- TimeSpan.cs
- ListBoxItemAutomationPeer.cs
- PropertyOverridesTypeEditor.cs
- Point3DCollection.cs
- Bits.cs
- HttpConfigurationContext.cs
- Function.cs
- TreeViewAutomationPeer.cs
- ItemTypeToolStripMenuItem.cs
- Pair.cs
- OracleDataReader.cs
- InputLanguageProfileNotifySink.cs
- ConfigViewGenerator.cs
- TextServicesCompartmentEventSink.cs
- XmlNodeComparer.cs
- _CookieModule.cs
- EntityDescriptor.cs
- RijndaelManagedTransform.cs
- FixedSOMContainer.cs