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
- XmlSerializerFormatAttribute.cs
- ToolStripPanelCell.cs
- RelativeSource.cs
- Polyline.cs
- DocumentSchemaValidator.cs
- Paragraph.cs
- DefaultIfEmptyQueryOperator.cs
- CapabilitiesRule.cs
- ScriptResourceMapping.cs
- ExpandableObjectConverter.cs
- ColorTransform.cs
- ArraySegment.cs
- AsymmetricSignatureFormatter.cs
- Font.cs
- DurationConverter.cs
- Types.cs
- DesignerFrame.cs
- XmlHelper.cs
- PropertyOverridesDialog.cs
- Visitors.cs
- Property.cs
- SqlRewriteScalarSubqueries.cs
- RelationshipEndMember.cs
- DbConnectionStringCommon.cs
- WindowsSysHeader.cs
- CustomErrorsSectionWrapper.cs
- Unit.cs
- FileRecordSequence.cs
- COM2AboutBoxPropertyDescriptor.cs
- OutputCacheSection.cs
- WebPartCloseVerb.cs
- HandlerWithFactory.cs
- List.cs
- DataPagerFieldItem.cs
- TextMessageEncodingBindingElement.cs
- ExecutionContext.cs
- NullableFloatMinMaxAggregationOperator.cs
- Relationship.cs
- Positioning.cs
- TablePattern.cs
- AutomationIdentifierGuids.cs
- StringToken.cs
- Style.cs
- SqlUdtInfo.cs
- SynchronizedReadOnlyCollection.cs
- Operator.cs
- AnnotationResource.cs
- CharacterHit.cs
- MetadataPropertyAttribute.cs
- NotifyParentPropertyAttribute.cs
- CodeMemberField.cs
- TablePattern.cs
- BoolLiteral.cs
- ViewService.cs
- SiteMapHierarchicalDataSourceView.cs
- TextElementEnumerator.cs
- WebPartZoneBase.cs
- _BufferOffsetSize.cs
- DataBindingExpressionBuilder.cs
- ToolStripActionList.cs
- XamlParser.cs
- ToolboxItemAttribute.cs
- SqlHelper.cs
- ClientSession.cs
- IntegerFacetDescriptionElement.cs
- Condition.cs
- LogRestartAreaEnumerator.cs
- RoleGroupCollectionEditor.cs
- TrackingDataItem.cs
- VirtualPathProvider.cs
- FontFamilyIdentifier.cs
- WizardPanel.cs
- DESCryptoServiceProvider.cs
- baseaxisquery.cs
- DesignerRegion.cs
- DataSourceCacheDurationConverter.cs
- AuthenticationModuleElementCollection.cs
- QilExpression.cs
- BitArray.cs
- WebAdminConfigurationHelper.cs
- cookiecollection.cs
- SqlBulkCopyColumnMapping.cs
- XmlEnumAttribute.cs
- Vector3DAnimationUsingKeyFrames.cs
- UpdateTranslator.cs
- TripleDESCryptoServiceProvider.cs
- SQLResource.cs
- DeclarativeCatalogPart.cs
- Rect.cs
- OneOf.cs
- StateMachineSubscription.cs
- EditingCommands.cs
- GifBitmapDecoder.cs
- ResourceKey.cs
- InfoCardProofToken.cs
- AspNetSynchronizationContext.cs
- VerificationAttribute.cs
- VirtualizedContainerService.cs
- ProvidersHelper.cs
- TransformedBitmap.cs