Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Internal / Utility / MonitorWrapper.cs / 1305600 / 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; } GC.SuppressFinalize(this); } 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
- ButtonFieldBase.cs
- _UncName.cs
- HttpResponseHeader.cs
- EventLogPermissionAttribute.cs
- WebControlParameterProxy.cs
- RemoteCryptoDecryptRequest.cs
- WsatServiceCertificate.cs
- ModuleConfigurationInfo.cs
- OrderPreservingPipeliningMergeHelper.cs
- SchemaImporterExtension.cs
- DataColumnPropertyDescriptor.cs
- BitmapMetadataBlob.cs
- Normalization.cs
- BasicExpressionVisitor.cs
- SizeAnimationUsingKeyFrames.cs
- SimpleHandlerFactory.cs
- ByteAnimation.cs
- IISMapPath.cs
- BaseTemplateBuildProvider.cs
- CodeLabeledStatement.cs
- AuthorizationSection.cs
- FieldToken.cs
- PerformanceCounterLib.cs
- IgnoreFileBuildProvider.cs
- EventPrivateKey.cs
- TextSchema.cs
- ParameterCollectionEditor.cs
- BmpBitmapDecoder.cs
- DataViewListener.cs
- VerificationAttribute.cs
- CompositeDataBoundControl.cs
- InputBinding.cs
- ProfileGroupSettingsCollection.cs
- RenderDataDrawingContext.cs
- RSACryptoServiceProvider.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- CallInfo.cs
- ProxyWebPartConnectionCollection.cs
- ModelPropertyImpl.cs
- MenuBindingsEditorForm.cs
- CompressedStack.cs
- Composition.cs
- Certificate.cs
- ExceptionValidationRule.cs
- CroppedBitmap.cs
- ImageClickEventArgs.cs
- WorkflowEnvironment.cs
- PassportPrincipal.cs
- QuaternionValueSerializer.cs
- QilReplaceVisitor.cs
- ToolStripOverflow.cs
- RefreshEventArgs.cs
- IssuanceLicense.cs
- XsltContext.cs
- DataServiceConfiguration.cs
- ProxyFragment.cs
- Form.cs
- SuppressMessageAttribute.cs
- ExpressionStringBuilder.cs
- IIS7UserPrincipal.cs
- SamlSubjectStatement.cs
- XpsFixedDocumentSequenceReaderWriter.cs
- Parameter.cs
- Crc32.cs
- Hash.cs
- CqlGenerator.cs
- BindingGroup.cs
- LostFocusEventManager.cs
- FileInfo.cs
- CodeDomSerializerBase.cs
- PropertyChangedEventManager.cs
- DiscoveryDocumentSerializer.cs
- SocketException.cs
- TextTreeDeleteContentUndoUnit.cs
- TreeViewItemAutomationPeer.cs
- CapabilitiesPattern.cs
- LookupNode.cs
- Win32Exception.cs
- DataKey.cs
- PackWebResponse.cs
- XmlSchemaObjectTable.cs
- InputElement.cs
- EditorZone.cs
- TargetParameterCountException.cs
- DeploymentSectionCache.cs
- AlternationConverter.cs
- Parser.cs
- AmbientValueAttribute.cs
- BitmapEffect.cs
- KeyPullup.cs
- SemanticKeyElement.cs
- SiteMapNodeItem.cs
- RegexFCD.cs
- SqlServer2KCompatibilityAnnotation.cs
- DynamicResourceExtension.cs
- StrongNamePublicKeyBlob.cs
- FontSizeConverter.cs
- SafeFileMapViewHandle.cs
- DetailsViewCommandEventArgs.cs
- FrameAutomationPeer.cs