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
- MostlySingletonList.cs
- PageWrapper.cs
- GPRECT.cs
- LambdaCompiler.ControlFlow.cs
- TransformPattern.cs
- ProviderIncompatibleException.cs
- GridViewColumnHeaderAutomationPeer.cs
- Cell.cs
- PasswordBox.cs
- ExpandedWrapper.cs
- TraceInternal.cs
- While.cs
- SmtpException.cs
- DataSourceProvider.cs
- QueueTransferProtocol.cs
- SessionEndingCancelEventArgs.cs
- _ListenerAsyncResult.cs
- TrustManager.cs
- PathNode.cs
- ToolTip.cs
- DataGridViewColumnHeaderCell.cs
- StylusPointProperty.cs
- VersionedStream.cs
- safelinkcollection.cs
- Utility.cs
- SessionState.cs
- CodeGotoStatement.cs
- CustomAssemblyResolver.cs
- VerificationAttribute.cs
- PatternMatcher.cs
- CheckBox.cs
- FileSystemWatcher.cs
- HttpConfigurationSystem.cs
- ModuleBuilder.cs
- ResourceSet.cs
- MonitorWrapper.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- XmlBoundElement.cs
- ShaperBuffers.cs
- ActivityPropertyReference.cs
- EastAsianLunisolarCalendar.cs
- XmlEntity.cs
- StrongNamePublicKeyBlob.cs
- DataGridViewCellPaintingEventArgs.cs
- SessionStateItemCollection.cs
- PasswordTextContainer.cs
- NotifyInputEventArgs.cs
- ManagementInstaller.cs
- PageBuildProvider.cs
- DataGridViewIntLinkedList.cs
- RuleSet.cs
- ValueChangedEventManager.cs
- PositiveTimeSpanValidator.cs
- GenericRootAutomationPeer.cs
- BufferedReceiveElement.cs
- Style.cs
- WebCategoryAttribute.cs
- HttpChannelBindingToken.cs
- ApplicationSecurityInfo.cs
- SapiInterop.cs
- FormsAuthenticationTicket.cs
- ItemCheckedEvent.cs
- HttpContextServiceHost.cs
- CodePropertyReferenceExpression.cs
- PackageRelationshipCollection.cs
- SynchronizedInputAdaptor.cs
- Viewport3DAutomationPeer.cs
- DoubleIndependentAnimationStorage.cs
- StringConverter.cs
- EventProxy.cs
- EventLogInternal.cs
- DataColumnCollection.cs
- RemoteWebConfigurationHostStream.cs
- WinEventTracker.cs
- ChangeProcessor.cs
- SqlDataSourceCommandEventArgs.cs
- XmlTextAttribute.cs
- ReadOnlyDictionary.cs
- BmpBitmapEncoder.cs
- LabelEditEvent.cs
- _DigestClient.cs
- FileDataSourceCache.cs
- Base64Decoder.cs
- FormView.cs
- SelectingProviderEventArgs.cs
- XmlCollation.cs
- RtType.cs
- SHA1Managed.cs
- ValidationResult.cs
- MetadataUtilsSmi.cs
- HttpHeaderCollection.cs
- SafeThreadHandle.cs
- TableCellCollection.cs
- ExpressionBuilderCollection.cs
- DateTimeFormatInfoScanner.cs
- IndexedGlyphRun.cs
- TextTreeRootTextBlock.cs
- ListViewInsertEventArgs.cs
- InvalidWMPVersionException.cs
- ToolStripSystemRenderer.cs