Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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[....] 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
- IssuanceLicense.cs
- BigIntegerStorage.cs
- CustomLineCap.cs
- ToolStripComboBox.cs
- GradientStop.cs
- EntityDesignerUtils.cs
- BindableAttribute.cs
- InnerItemCollectionView.cs
- ResourceReader.cs
- SemanticResultKey.cs
- UserPreferenceChangingEventArgs.cs
- TemplateBuilder.cs
- SqlNotificationEventArgs.cs
- ServiceModelSectionGroup.cs
- HyperLinkColumn.cs
- CounterCreationDataCollection.cs
- WindowsListBox.cs
- GeneralTransform3DGroup.cs
- WebBrowserUriTypeConverter.cs
- TextDpi.cs
- documentsequencetextpointer.cs
- SplitterEvent.cs
- PointKeyFrameCollection.cs
- GridViewEditEventArgs.cs
- MatrixConverter.cs
- BooleanAnimationUsingKeyFrames.cs
- AssemblySettingAttributes.cs
- XPathSelectionIterator.cs
- AlphaSortedEnumConverter.cs
- PreProcessInputEventArgs.cs
- WindowPattern.cs
- ConfigurationStrings.cs
- DataGridViewCell.cs
- SHA1Managed.cs
- SubclassTypeValidator.cs
- NullableDecimalSumAggregationOperator.cs
- RuleValidation.cs
- DoubleLinkList.cs
- QuadraticBezierSegment.cs
- DecoderFallbackWithFailureFlag.cs
- ObjectPropertyMapping.cs
- ResourcePool.cs
- Knowncolors.cs
- ContentType.cs
- COAUTHINFO.cs
- ToolStripAdornerWindowService.cs
- RestClientProxyHandler.cs
- LookupBindingPropertiesAttribute.cs
- ParseNumbers.cs
- ProjectionQueryOptionExpression.cs
- AppSettingsExpressionBuilder.cs
- BrowserCapabilitiesFactory.cs
- Color.cs
- Executor.cs
- DecoderExceptionFallback.cs
- TrustLevelCollection.cs
- NameTable.cs
- HandlerMappingMemo.cs
- PersonalizationEntry.cs
- DragStartedEventArgs.cs
- ResourcePermissionBase.cs
- LockCookie.cs
- EntityDataSourceChangedEventArgs.cs
- StreamWithDictionary.cs
- CatalogPartCollection.cs
- Sentence.cs
- StringReader.cs
- WinFormsSpinner.cs
- StringFreezingAttribute.cs
- AnimatedTypeHelpers.cs
- JumpTask.cs
- ArithmeticException.cs
- NonParentingControl.cs
- IDQuery.cs
- ObjectReaderCompiler.cs
- MemoryRecordBuffer.cs
- VariantWrapper.cs
- WindowsIdentity.cs
- objectresult_tresulttype.cs
- DocumentSequenceHighlightLayer.cs
- CapabilitiesUse.cs
- PropertyOverridesTypeEditor.cs
- SystemInfo.cs
- ChangePassword.cs
- DbMetaDataCollectionNames.cs
- XmlSchemaAny.cs
- XmlImplementation.cs
- ConfigurationProperty.cs
- InternalDispatchObject.cs
- ConnectionPoint.cs
- RawStylusInputCustomDataList.cs
- TableCellAutomationPeer.cs
- TypeDescriptorFilterService.cs
- ExtendedProperty.cs
- DataKey.cs
- ObjectQuery.cs
- PageThemeBuildProvider.cs
- Listbox.cs
- ThrowHelper.cs
- Stackframe.cs