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
- PopupEventArgs.cs
- ObjectTokenCategory.cs
- XmlSchemaSequence.cs
- RadialGradientBrush.cs
- Drawing.cs
- Triplet.cs
- WebReferenceOptions.cs
- SqlMethodCallConverter.cs
- GregorianCalendarHelper.cs
- XmlSchemaSet.cs
- SecurityTokenResolver.cs
- DialogResultConverter.cs
- HtmlShim.cs
- VirtualPathData.cs
- VerbConverter.cs
- ProtectedConfigurationSection.cs
- OperatingSystem.cs
- PropertyIDSet.cs
- RegistrationServices.cs
- DoubleAnimationBase.cs
- WebPartMinimizeVerb.cs
- DataGridLinkButton.cs
- InternalResources.cs
- EditorResources.cs
- ContentFilePart.cs
- FileSecurity.cs
- GuidTagList.cs
- TableItemPattern.cs
- EventSetter.cs
- ListDictionaryInternal.cs
- MessageQueuePermissionEntryCollection.cs
- BaseConfigurationRecord.cs
- SystemTcpConnection.cs
- DrawingGroup.cs
- HighlightOverlayGlyph.cs
- GridPattern.cs
- SelectionPattern.cs
- PKCS1MaskGenerationMethod.cs
- SqlClientWrapperSmiStream.cs
- RsaSecurityToken.cs
- PointAnimationUsingKeyFrames.cs
- QuaternionRotation3D.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- PreProcessInputEventArgs.cs
- ServiceContractListItem.cs
- PanelStyle.cs
- CapacityStreamGeometryContext.cs
- GridSplitterAutomationPeer.cs
- FileFormatException.cs
- InputMethod.cs
- ColorAnimationBase.cs
- RemotingServices.cs
- mactripleDES.cs
- ResumeStoryboard.cs
- StylusEventArgs.cs
- mediapermission.cs
- MultilineStringEditor.cs
- FirstMatchCodeGroup.cs
- HashAlgorithm.cs
- DataTableMapping.cs
- BuildProvidersCompiler.cs
- BitmapEffectState.cs
- FormViewInsertEventArgs.cs
- DefaultValueConverter.cs
- StackBuilderSink.cs
- MimeXmlReflector.cs
- TreeViewHitTestInfo.cs
- CodeArrayIndexerExpression.cs
- Gdiplus.cs
- MetabaseReader.cs
- OfTypeExpression.cs
- WebConfigurationHost.cs
- Unit.cs
- XmlSchemaComplexContentExtension.cs
- HelpEvent.cs
- ExpressionWriter.cs
- XamlClipboardData.cs
- WaitHandle.cs
- RoleManagerEventArgs.cs
- MembershipSection.cs
- BeginEvent.cs
- Sql8ExpressionRewriter.cs
- RuntimeCompatibilityAttribute.cs
- CngAlgorithmGroup.cs
- AsymmetricAlgorithm.cs
- FormatConvertedBitmap.cs
- ToolStripSeparator.cs
- EndpointIdentityExtension.cs
- TypeValidationEventArgs.cs
- ScrollPattern.cs
- XmlRawWriter.cs
- StringInfo.cs
- JsonFormatWriterGenerator.cs
- SqlDataSourceSelectingEventArgs.cs
- GlobalizationAssembly.cs
- ToolZone.cs
- InstanceContextMode.cs
- FontCollection.cs
- SmtpReplyReaderFactory.cs
- EventProxy.cs