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
- ConvertBinder.cs
- HostedElements.cs
- ProfileBuildProvider.cs
- SystemWebCachingSectionGroup.cs
- PerformanceCountersElement.cs
- FileLevelControlBuilderAttribute.cs
- NonSerializedAttribute.cs
- TextEffectCollection.cs
- DataGridToolTip.cs
- ThreadExceptionDialog.cs
- SecUtil.cs
- WizardStepBase.cs
- ViewValidator.cs
- ObjectKeyFrameCollection.cs
- processwaithandle.cs
- ListViewItem.cs
- SqlUtils.cs
- SchemaType.cs
- MenuAdapter.cs
- SolidColorBrush.cs
- PrimitiveDataContract.cs
- CalendarAutoFormatDialog.cs
- SoapWriter.cs
- XamlTypeMapperSchemaContext.cs
- SafeHandles.cs
- TextOutput.cs
- PopupEventArgs.cs
- RijndaelManaged.cs
- OleDbErrorCollection.cs
- ActiveXSite.cs
- CroppedBitmap.cs
- FusionWrap.cs
- ElementNotEnabledException.cs
- PrivilegedConfigurationManager.cs
- ZipIOExtraField.cs
- FastEncoder.cs
- DrawingAttributeSerializer.cs
- SamlSecurityTokenAuthenticator.cs
- ActivatedMessageQueue.cs
- IntegerCollectionEditor.cs
- XmlDictionary.cs
- ActivityDesignerLayoutSerializers.cs
- MarginCollapsingState.cs
- ValidationEventArgs.cs
- IntSumAggregationOperator.cs
- DocumentPaginator.cs
- CompletedAsyncResult.cs
- ListParaClient.cs
- XmlSignatureProperties.cs
- ProfileService.cs
- SHA1CryptoServiceProvider.cs
- ParseChildrenAsPropertiesAttribute.cs
- TypeAccessException.cs
- StateItem.cs
- HybridWebProxyFinder.cs
- parserscommon.cs
- UserInitiatedRoutedEventPermission.cs
- RichTextBoxContextMenu.cs
- FilterException.cs
- HWStack.cs
- httpstaticobjectscollection.cs
- LoginCancelEventArgs.cs
- ListSortDescription.cs
- HostSecurityManager.cs
- Command.cs
- SingleObjectCollection.cs
- SignatureDescription.cs
- ListView.cs
- ActionNotSupportedException.cs
- MaterialGroup.cs
- ConfigXmlAttribute.cs
- AbandonedMutexException.cs
- TargetFrameworkAttribute.cs
- PrintController.cs
- Codec.cs
- OciHandle.cs
- FrugalList.cs
- Animatable.cs
- MessageQueueAccessControlEntry.cs
- SimpleHandlerFactory.cs
- Encoder.cs
- XmlSchemaComplexContentExtension.cs
- ObjectDataSourceView.cs
- DateTimeSerializationSection.cs
- OleStrCAMarshaler.cs
- PropVariant.cs
- OleDbConnection.cs
- DataGridViewTopLeftHeaderCell.cs
- initElementDictionary.cs
- XsltSettings.cs
- DataTableTypeConverter.cs
- QueueProcessor.cs
- SmiContextFactory.cs
- Buffer.cs
- Compiler.cs
- reliableinputsessionchannel.cs
- NavigationPropertyEmitter.cs
- TreeViewCancelEvent.cs
- UserControlDocumentDesigner.cs
- PartitionedStreamMerger.cs