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
- FormatSettings.cs
- XmlSignatureManifest.cs
- StoreAnnotationsMap.cs
- Lease.cs
- XmlWrappingReader.cs
- TextTreeObjectNode.cs
- InternalPermissions.cs
- CodeAttributeDeclarationCollection.cs
- CustomCategoryAttribute.cs
- ForceCopyBuildProvider.cs
- PreviewKeyDownEventArgs.cs
- _AutoWebProxyScriptWrapper.cs
- ValidationErrorCollection.cs
- RightsManagementInformation.cs
- BufferModesCollection.cs
- ObservableDictionary.cs
- ObjectDataSourceFilteringEventArgs.cs
- AuthenticationModuleElement.cs
- PeerInputChannel.cs
- Walker.cs
- HMACSHA512.cs
- Automation.cs
- IdentifierCreationService.cs
- TextRunCacheImp.cs
- XmlKeywords.cs
- ComponentResourceKeyConverter.cs
- GetTokenRequest.cs
- MembershipValidatePasswordEventArgs.cs
- UserPreferenceChangingEventArgs.cs
- MethodBody.cs
- BindingElementExtensionElement.cs
- TrustLevelCollection.cs
- XmlSchemaAnnotation.cs
- Guid.cs
- SymmetricSecurityBindingElement.cs
- StringWriter.cs
- FormattedTextSymbols.cs
- ReflectionTypeLoadException.cs
- MetadataCollection.cs
- ToolStripLabel.cs
- PseudoWebRequest.cs
- LogLogRecordHeader.cs
- XsdDateTime.cs
- StyleSheet.cs
- KoreanLunisolarCalendar.cs
- CookieProtection.cs
- PropertyGridCommands.cs
- ProgressiveCrcCalculatingStream.cs
- LinqDataSourceDisposeEventArgs.cs
- TextElementEnumerator.cs
- OdbcConnectionPoolProviderInfo.cs
- InstancePersistenceException.cs
- XmlAttributeHolder.cs
- KeyboardNavigation.cs
- metadatamappinghashervisitor.cs
- ClientOptions.cs
- MailMessage.cs
- FixedPage.cs
- HtmlHistory.cs
- DataGridViewComboBoxCell.cs
- TextAutomationPeer.cs
- TypeDelegator.cs
- GridLengthConverter.cs
- MatrixAnimationBase.cs
- Application.cs
- DbLambda.cs
- ApplicationSecurityManager.cs
- ListViewPagedDataSource.cs
- CellTreeNodeVisitors.cs
- XmlQuerySequence.cs
- RawStylusInputCustomData.cs
- ResolveCriteriaApril2005.cs
- TimelineCollection.cs
- DeviceFiltersSection.cs
- AppDomainProtocolHandler.cs
- StandardRuntimeEnumValidator.cs
- DoWorkEventArgs.cs
- TypeBuilderInstantiation.cs
- ProjectionCamera.cs
- ConfigurationSchemaErrors.cs
- PreviewPageInfo.cs
- StringInfo.cs
- DataGridViewCellCollection.cs
- String.cs
- XmlSchemaNotation.cs
- SchemaImporterExtensionsSection.cs
- WmlTextViewAdapter.cs
- KeySplineConverter.cs
- RegexFCD.cs
- KernelTypeValidation.cs
- XPathParser.cs
- ViewStateException.cs
- DbMetaDataColumnNames.cs
- VersionConverter.cs
- InvalidOleVariantTypeException.cs
- PropertyEntry.cs
- ScrollBarAutomationPeer.cs
- SystemWebExtensionsSectionGroup.cs
- ScriptRegistrationManager.cs
- XmlDesignerDataSourceView.cs