Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Runtime / Remoting / LeaseManager.cs / 1 / LeaseManager.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //+---------------------------------------------------------------------------- // // Microsoft Windows // File: LeaseManager.cs // // Contents: Administers the leases in an appdomain // // History: 1/5/00[....] Created // //+--------------------------------------------------------------------------- namespace System.Runtime.Remoting.Lifetime { using System; using System.Collections; using System.Threading; internal class LeaseManager { // Lease Lists private Hashtable leaseToTimeTable = new Hashtable(); // Async Sponsor Calls //private SortedList sponsorCallList = new SortedList(); private Hashtable sponsorTable = new Hashtable(); // LeaseTimeAnalyzer thread private TimeSpan pollTime; AutoResetEvent waitHandle; TimerCallback leaseTimeAnalyzerDelegate; private volatile Timer leaseTimer; internal static bool IsInitialized() { DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; LeaseManager leaseManager = remotingData.LeaseManager; return leaseManager != null; } internal static LeaseManager GetLeaseManager(TimeSpan pollTime) { DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; LeaseManager leaseManager = remotingData.LeaseManager; if (leaseManager == null) { lock (remotingData) { if (remotingData.LeaseManager == null) { remotingData.LeaseManager = new LeaseManager(pollTime); } leaseManager = remotingData.LeaseManager; } } return leaseManager; } internal static LeaseManager GetLeaseManager() { DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; LeaseManager leaseManager = remotingData.LeaseManager; BCLDebug.Assert(leaseManager != null, "[LeaseManager.GetLeaseManager()]leaseManager !=null"); return leaseManager; } private LeaseManager(TimeSpan pollTime) { BCLDebug.Trace("REMOTE","LeaseManager Constructor"); this.pollTime = pollTime; leaseTimeAnalyzerDelegate = new TimerCallback(this.LeaseTimeAnalyzer); waitHandle = new AutoResetEvent(false); // We need to create a Timer with Infinite dueTime to ensure that // leaseTimeAnalyzerDelegate doesnt get invoked before leaseTimer is initialized // Once initialized we can change it to the appropriate dueTime leaseTimer = new Timer(leaseTimeAnalyzerDelegate, null, Timeout.Infinite, Timeout.Infinite); leaseTimer.Change((int)pollTime.TotalMilliseconds, Timeout.Infinite); } internal void ChangePollTime(TimeSpan pollTime) { BCLDebug.Trace("REMOTE","LeaseManager ChangePollTime ", pollTime); this.pollTime = pollTime; } internal void ActivateLease(Lease lease) { BCLDebug.Trace("REMOTE","LeaseManager AddLease ",lease.id," ",lease.managedObject); lock(leaseToTimeTable) { leaseToTimeTable[lease] = lease.leaseTime; } } internal void DeleteLease(Lease lease) { BCLDebug.Trace("REMOTE","LeaseManager DeleteLease ",lease.id); lock(leaseToTimeTable) { leaseToTimeTable.Remove(lease); } } [System.Diagnostics.Conditional("_LOGGING")] internal void DumpLeases(Lease[] leases) { for (int i=0; i
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- altserialization.cs
- EntityModelSchemaGenerator.cs
- FrugalList.cs
- SystemIcmpV4Statistics.cs
- DataControlPagerLinkButton.cs
- EntityDataSourceEntityTypeFilterItem.cs
- TextBoxBase.cs
- BasicHttpBinding.cs
- DataFormats.cs
- PresentationTraceSources.cs
- SqlComparer.cs
- Win32SafeHandles.cs
- ExpressionVisitorHelpers.cs
- RuleProcessor.cs
- FormViewInsertEventArgs.cs
- FieldToken.cs
- Decimal.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- CompiledXpathExpr.cs
- SoapObjectInfo.cs
- UriTemplateDispatchFormatter.cs
- GenericPrincipal.cs
- InvariantComparer.cs
- GenericIdentity.cs
- ImpersonateTokenRef.cs
- XmlSchemaSequence.cs
- SafeCryptContextHandle.cs
- TextModifier.cs
- SortFieldComparer.cs
- DbModificationCommandTree.cs
- StringValidatorAttribute.cs
- DataControlFieldHeaderCell.cs
- DateTimeStorage.cs
- XpsFilter.cs
- AssemblyBuilder.cs
- BinaryEditor.cs
- ToolStripDropDownMenu.cs
- DataGridClipboardCellContent.cs
- FilterException.cs
- XamlDesignerSerializationManager.cs
- SqlConnectionStringBuilder.cs
- ApplicationServiceManager.cs
- FontWeights.cs
- EncryptedReference.cs
- MenuItemAutomationPeer.cs
- DesignerCalendarAdapter.cs
- TreeNodeStyleCollection.cs
- DataServicePagingProviderWrapper.cs
- BitmapVisualManager.cs
- BitmapMetadata.cs
- NetTcpBinding.cs
- WmfPlaceableFileHeader.cs
- ConfigurationSection.cs
- MappingMetadataHelper.cs
- OuterGlowBitmapEffect.cs
- DesignOnlyAttribute.cs
- COM2ComponentEditor.cs
- SqlIdentifier.cs
- PassportPrincipal.cs
- XmlSchemaSimpleTypeUnion.cs
- EntityException.cs
- Crc32.cs
- MouseButtonEventArgs.cs
- DataGridCommandEventArgs.cs
- OdbcConnection.cs
- SqlDataReaderSmi.cs
- EntityStoreSchemaFilterEntry.cs
- SpotLight.cs
- TimeSpanValidator.cs
- FormViewPageEventArgs.cs
- TrackingRecord.cs
- KnownIds.cs
- NameValueConfigurationElement.cs
- InstanceDataCollectionCollection.cs
- DeploymentSection.cs
- XmlDeclaration.cs
- ADMembershipProvider.cs
- CompilerError.cs
- SecurityVerifiedMessage.cs
- WriteFileContext.cs
- NameService.cs
- PrintDialog.cs
- DataGridViewImageColumn.cs
- HighContrastHelper.cs
- PointHitTestParameters.cs
- TextContainer.cs
- ConfigurationLockCollection.cs
- CachedCompositeFamily.cs
- UpdateProgress.cs
- ServerValidateEventArgs.cs
- ProtocolsSection.cs
- CacheAxisQuery.cs
- CallbackException.cs
- KeyTimeConverter.cs
- ITextView.cs
- SynchronizedDispatch.cs
- StatusCommandUI.cs
- EdmToObjectNamespaceMap.cs
- WebAdminConfigurationHelper.cs
- PropertyEmitterBase.cs