Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Metadata / ObjectLayer / LockedAssemblyCache.cs / 1305376 / LockedAssemblyCache.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Threading; namespace System.Data.Metadata.Edm { internal class LockedAssemblyCache : IDisposable { private object _lockObject; private Dictionary_globalAssemblyCache; internal LockedAssemblyCache(object lockObject, Dictionary globalAssemblyCache) { _lockObject = lockObject; _globalAssemblyCache = globalAssemblyCache; #pragma warning disable 0618 //@ Monitor.Enter(_lockObject); #pragma warning restore 0618 } public void Dispose() { // Technically, calling GC.SuppressFinalize is not required because the class does not // have a finalizer, but it does no harm, protects against the case where a finalizer is added // in the future, and prevents an FxCop warning. GC.SuppressFinalize(this); Monitor.Exit(_lockObject); _lockObject = null; _globalAssemblyCache = null; } [Conditional("DEBUG")] private void AssertLockedByThisThread() { bool entered = false; Monitor.TryEnter(_lockObject, ref entered); if (entered) { Monitor.Exit(_lockObject); } Debug.Assert(entered, "The cache is being accessed by a thread that isn't holding the lock"); } internal bool TryGetValue(Assembly assembly, out ImmutableAssemblyCacheEntry cacheEntry) { AssertLockedByThisThread(); return _globalAssemblyCache.TryGetValue(assembly, out cacheEntry); } internal void Add(Assembly assembly, ImmutableAssemblyCacheEntry assemblyCacheEntry) { AssertLockedByThisThread(); _globalAssemblyCache.Add(assembly, assemblyCacheEntry); } internal void Clear() { AssertLockedByThisThread(); _globalAssemblyCache.Clear(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Threading; namespace System.Data.Metadata.Edm { internal class LockedAssemblyCache : IDisposable { private object _lockObject; private Dictionary_globalAssemblyCache; internal LockedAssemblyCache(object lockObject, Dictionary globalAssemblyCache) { _lockObject = lockObject; _globalAssemblyCache = globalAssemblyCache; #pragma warning disable 0618 //@ Monitor.Enter(_lockObject); #pragma warning restore 0618 } public void Dispose() { // Technically, calling GC.SuppressFinalize is not required because the class does not // have a finalizer, but it does no harm, protects against the case where a finalizer is added // in the future, and prevents an FxCop warning. GC.SuppressFinalize(this); Monitor.Exit(_lockObject); _lockObject = null; _globalAssemblyCache = null; } [Conditional("DEBUG")] private void AssertLockedByThisThread() { bool entered = false; Monitor.TryEnter(_lockObject, ref entered); if (entered) { Monitor.Exit(_lockObject); } Debug.Assert(entered, "The cache is being accessed by a thread that isn't holding the lock"); } internal bool TryGetValue(Assembly assembly, out ImmutableAssemblyCacheEntry cacheEntry) { AssertLockedByThisThread(); return _globalAssemblyCache.TryGetValue(assembly, out cacheEntry); } internal void Add(Assembly assembly, ImmutableAssemblyCacheEntry assemblyCacheEntry) { AssertLockedByThisThread(); _globalAssemblyCache.Add(assembly, assemblyCacheEntry); } internal void Clear() { AssertLockedByThisThread(); _globalAssemblyCache.Clear(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FindCriteria.cs
- TimeSpanOrInfiniteConverter.cs
- ECDiffieHellmanCng.cs
- Query.cs
- DataGridViewBand.cs
- HttpFileCollectionBase.cs
- PartialCachingAttribute.cs
- ScrollBarRenderer.cs
- ReadContentAsBinaryHelper.cs
- InertiaExpansionBehavior.cs
- Rect3D.cs
- SafeArrayRankMismatchException.cs
- ApplicationInfo.cs
- StrongTypingException.cs
- WebException.cs
- DesignTimeDataBinding.cs
- SdlChannelSink.cs
- DataGridViewRowStateChangedEventArgs.cs
- TreeNode.cs
- TimeBoundedCache.cs
- WebPartConnectionsCancelEventArgs.cs
- X509CertificateTokenFactoryCredential.cs
- SoapSchemaMember.cs
- SmiMetaData.cs
- PointAnimation.cs
- SecurityKeyIdentifier.cs
- sqlpipe.cs
- WeakRefEnumerator.cs
- DbTransaction.cs
- VisualStyleElement.cs
- OutOfMemoryException.cs
- WaitForChangedResult.cs
- SystemFonts.cs
- PolyBezierSegmentFigureLogic.cs
- PersonalizationProviderHelper.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- XmlUnspecifiedAttribute.cs
- ConnectionPoint.cs
- HostVisual.cs
- WsdlBuildProvider.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- Transform3DGroup.cs
- XmlLanguageConverter.cs
- HttpModuleAction.cs
- ValidationResult.cs
- MatrixTransform3D.cs
- CustomWebEventKey.cs
- CqlErrorHelper.cs
- OleDbRowUpdatedEvent.cs
- IdnMapping.cs
- Utils.cs
- RtfControlWordInfo.cs
- InvokeProviderWrapper.cs
- CompilerCollection.cs
- MappingMetadataHelper.cs
- VisualBasicExpressionConverter.cs
- Separator.cs
- ToolStripHighContrastRenderer.cs
- ToolboxDataAttribute.cs
- UnmanagedMemoryStreamWrapper.cs
- MinimizableAttributeTypeConverter.cs
- SplineKeyFrames.cs
- ConfigurationProperty.cs
- ApplicationSecurityManager.cs
- XMLSchema.cs
- NativeMethods.cs
- InputScope.cs
- CompiledRegexRunner.cs
- RemotingServices.cs
- ControlBindingsCollection.cs
- EmissiveMaterial.cs
- IconConverter.cs
- HttpPostedFile.cs
- Rect3DConverter.cs
- WindowVisualStateTracker.cs
- WebPartZoneCollection.cs
- Imaging.cs
- TemplateControlParser.cs
- EntityStoreSchemaFilterEntry.cs
- PointHitTestParameters.cs
- DependencyPropertyValueSerializer.cs
- ExpressionVisitor.cs
- SHA256.cs
- AuthorizationPolicyTypeElement.cs
- CompleteWizardStep.cs
- AesCryptoServiceProvider.cs
- IteratorFilter.cs
- SoapDocumentMethodAttribute.cs
- TextDecoration.cs
- XmlIncludeAttribute.cs
- InkCanvas.cs
- NetworkInformationException.cs
- IndexOutOfRangeException.cs
- AsyncPostBackTrigger.cs
- counter.cs
- SingleTagSectionHandler.cs
- ConditionChanges.cs
- TimelineClockCollection.cs
- RootProfilePropertySettingsCollection.cs
- TreeNodeConverter.cs