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
- DocumentPage.cs
- ComponentRenameEvent.cs
- EventLogException.cs
- StackBuilderSink.cs
- IteratorFilter.cs
- EncodingInfo.cs
- XMLSchema.cs
- FontSource.cs
- TreeNodeBinding.cs
- ExceptionWrapper.cs
- FloaterBaseParaClient.cs
- TextPointerBase.cs
- documentsequencetextview.cs
- PenThreadWorker.cs
- OdbcCommand.cs
- ListViewItemMouseHoverEvent.cs
- FormsAuthenticationModule.cs
- hwndwrapper.cs
- DiscoveryDocumentSearchPattern.cs
- ValidationSummary.cs
- TextTreeInsertUndoUnit.cs
- NullableIntAverageAggregationOperator.cs
- DateTimeFormat.cs
- ListViewTableRow.cs
- PointHitTestParameters.cs
- WebPartEditorCancelVerb.cs
- SizeAnimationClockResource.cs
- FixedDocument.cs
- ColorBlend.cs
- WinInetCache.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- RadioButton.cs
- CapabilitiesState.cs
- HttpProfileBase.cs
- DataGrid.cs
- KeyValueSerializer.cs
- XmlUtf8RawTextWriter.cs
- ECDsa.cs
- StatusStrip.cs
- BindingMAnagerBase.cs
- SqlBooleanizer.cs
- MediaElement.cs
- CodeAccessPermission.cs
- FontClient.cs
- ClassGenerator.cs
- DTCTransactionManager.cs
- ComboBox.cs
- RegisteredExpandoAttribute.cs
- ColumnReorderedEventArgs.cs
- BindableTemplateBuilder.cs
- TextElementEditingBehaviorAttribute.cs
- PageMediaType.cs
- TileBrush.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- LessThanOrEqual.cs
- DataReaderContainer.cs
- ObjectReaderCompiler.cs
- CalendarBlackoutDatesCollection.cs
- DataObjectAttribute.cs
- ExpressionEditorAttribute.cs
- PatternMatcher.cs
- XMLDiffLoader.cs
- PEFileReader.cs
- unitconverter.cs
- baseaxisquery.cs
- TlsSspiNegotiation.cs
- InertiaTranslationBehavior.cs
- PageAdapter.cs
- PeerCollaboration.cs
- ChildDocumentBlock.cs
- SafeCryptContextHandle.cs
- DrawingGroup.cs
- SoundPlayer.cs
- ADMembershipProvider.cs
- TextRunCache.cs
- DragCompletedEventArgs.cs
- WebServiceEnumData.cs
- UnsafeNativeMethodsTablet.cs
- MultiSelector.cs
- MulticastDelegate.cs
- ScrollContentPresenter.cs
- MouseGestureValueSerializer.cs
- SignedPkcs7.cs
- UnSafeCharBuffer.cs
- WorkflowElementDialog.cs
- ExtensibleClassFactory.cs
- DataChangedEventManager.cs
- SqlVisitor.cs
- GuidelineCollection.cs
- NativeMethods.cs
- MaskedTextProvider.cs
- CollectionViewProxy.cs
- path.cs
- ListViewInsertEventArgs.cs
- TextSegment.cs
- SafeThreadHandle.cs
- BindingContext.cs
- DesignTimeHTMLTextWriter.cs
- FormsAuthenticationCredentials.cs
- TextChangedEventArgs.cs