Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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
- TransportConfigurationTypeElement.cs
- ConditionalWeakTable.cs
- DictionaryEntry.cs
- HashJoinQueryOperatorEnumerator.cs
- TemplatedAdorner.cs
- DataGridPagingPage.cs
- ThreadNeutralSemaphore.cs
- BorderSidesEditor.cs
- IEnumerable.cs
- RelatedEnd.cs
- RuntimeEnvironment.cs
- VerificationAttribute.cs
- Vector3DCollection.cs
- Buffer.cs
- FixedTextSelectionProcessor.cs
- Wildcard.cs
- SecurityVersion.cs
- FullTextState.cs
- Expander.cs
- MutexSecurity.cs
- PopupRoot.cs
- EnumerableRowCollectionExtensions.cs
- ViewStateModeByIdAttribute.cs
- ParameterReplacerVisitor.cs
- GotoExpression.cs
- ChangePasswordAutoFormat.cs
- GreenMethods.cs
- OutputScopeManager.cs
- MapPathBasedVirtualPathProvider.cs
- HostAdapter.cs
- HTTPNotFoundHandler.cs
- SyndicationSerializer.cs
- ValueQuery.cs
- MouseGestureValueSerializer.cs
- Cursor.cs
- BamlCollectionHolder.cs
- StreamGeometry.cs
- ISAPIWorkerRequest.cs
- HttpException.cs
- FileCodeGroup.cs
- CapabilitiesPattern.cs
- ReflectionTypeLoadException.cs
- EasingKeyFrames.cs
- ResolveResponseInfo.cs
- Command.cs
- InOutArgument.cs
- ControlBindingsCollection.cs
- Label.cs
- TreeNodeConverter.cs
- XsdDuration.cs
- MissingFieldException.cs
- CodeIdentifier.cs
- InkCanvasSelectionAdorner.cs
- IndependentlyAnimatedPropertyMetadata.cs
- basevalidator.cs
- WindowPattern.cs
- UInt32.cs
- ChtmlTextWriter.cs
- MostlySingletonList.cs
- Brushes.cs
- MyContact.cs
- MouseButton.cs
- DataGridViewButtonColumn.cs
- HttpHandlersSection.cs
- SQLBinaryStorage.cs
- AvtEvent.cs
- Application.cs
- HttpHandler.cs
- SqlMultiplexer.cs
- SafeSecurityHelper.cs
- ManualResetEvent.cs
- DbProviderFactories.cs
- VisualCollection.cs
- BorderGapMaskConverter.cs
- XmlSortKey.cs
- XmlLinkedNode.cs
- BooleanExpr.cs
- SettingsPropertyWrongTypeException.cs
- SettingsPropertyWrongTypeException.cs
- DefaultWorkflowSchedulerService.cs
- DataGridItem.cs
- MultiPropertyDescriptorGridEntry.cs
- SimpleHandlerBuildProvider.cs
- ClientSettingsProvider.cs
- DictionaryEntry.cs
- SqlProvider.cs
- ProfilePropertySettings.cs
- CacheEntry.cs
- TextEditorCharacters.cs
- RecordManager.cs
- ToolbarAUtomationPeer.cs
- ThreadExceptionDialog.cs
- ClientTargetSection.cs
- BindingContext.cs
- SeekStoryboard.cs
- BamlResourceSerializer.cs
- AbsoluteQuery.cs
- WorkflowInspectionServices.cs
- NameSpaceExtractor.cs
- FontDriver.cs