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
- DataGridViewColumnEventArgs.cs
- WebServiceFault.cs
- COMException.cs
- AcceptorSessionSymmetricMessageSecurityProtocol.cs
- HiddenField.cs
- COAUTHINFO.cs
- Compress.cs
- IntMinMaxAggregationOperator.cs
- GenericPrincipal.cs
- SplashScreenNativeMethods.cs
- EntityContainer.cs
- SimpleHandlerFactory.cs
- CacheEntry.cs
- PartitionedStream.cs
- MemoryFailPoint.cs
- ButtonBaseDesigner.cs
- SoapHeaderAttribute.cs
- XPathScanner.cs
- ComponentResourceKeyConverter.cs
- Array.cs
- SelectedCellsChangedEventArgs.cs
- PersonalizationState.cs
- Math.cs
- ToolBarButton.cs
- ProfilePropertyNameValidator.cs
- CompositeCollectionView.cs
- KeyValuePair.cs
- ProtocolsSection.cs
- MethodImplAttribute.cs
- CodeEntryPointMethod.cs
- UserInitiatedRoutedEventPermissionAttribute.cs
- HGlobalSafeHandle.cs
- HyperLink.cs
- GenericXmlSecurityToken.cs
- Soap12ProtocolImporter.cs
- XmlSchemaSet.cs
- FilteredDataSetHelper.cs
- ModelPerspective.cs
- DataGridItemCollection.cs
- OleDbMetaDataFactory.cs
- HitTestDrawingContextWalker.cs
- RemoteWebConfigurationHost.cs
- LocalizationParserHooks.cs
- FontResourceCache.cs
- GACIdentityPermission.cs
- _SafeNetHandles.cs
- PlatformCulture.cs
- _UriTypeConverter.cs
- NetCodeGroup.cs
- PersonalizationState.cs
- WebSysDisplayNameAttribute.cs
- ScriptReferenceBase.cs
- TemplatedMailWebEventProvider.cs
- IsolatedStoragePermission.cs
- CharStorage.cs
- InstanceLockLostException.cs
- UnicastIPAddressInformationCollection.cs
- VisualTreeHelper.cs
- TraceUtility.cs
- CaseInsensitiveHashCodeProvider.cs
- LayoutSettings.cs
- WpfWebRequestHelper.cs
- WebGetAttribute.cs
- NonBatchDirectoryCompiler.cs
- TextSpanModifier.cs
- CharEnumerator.cs
- ParserOptions.cs
- SHA1Managed.cs
- ExpressionBuilder.cs
- DockEditor.cs
- Rfc4050KeyFormatter.cs
- ContractMethodInfo.cs
- MasterPageCodeDomTreeGenerator.cs
- BitmapEffectInput.cs
- PageWrapper.cs
- JsonQNameDataContract.cs
- XmlTextWriter.cs
- ExceptionTrace.cs
- DataTemplateSelector.cs
- SqlFileStream.cs
- AttributeEmitter.cs
- COM2Enum.cs
- HeaderCollection.cs
- AttributeUsageAttribute.cs
- OnOperation.cs
- TemplateField.cs
- OutputScopeManager.cs
- Cloud.cs
- EntityDataSourceState.cs
- LZCodec.cs
- TextParentUndoUnit.cs
- ExpressionBindingCollection.cs
- DirectoryInfo.cs
- ToolboxComponentsCreatedEventArgs.cs
- OLEDB_Util.cs
- ITreeGenerator.cs
- FormClosingEvent.cs
- MailDefinition.cs
- DesignSurfaceServiceContainer.cs
- X509CertificateTokenFactoryCredential.cs