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
- ComponentCollection.cs
- GradientSpreadMethodValidation.cs
- SqlDataSourceView.cs
- M3DUtil.cs
- MetadataArtifactLoaderCompositeFile.cs
- Tuple.cs
- DynamicResourceExtension.cs
- ColorConvertedBitmap.cs
- HtmlTableRowCollection.cs
- WindowsPen.cs
- Compilation.cs
- ToolStripDropDown.cs
- TextBounds.cs
- DataSourceIDConverter.cs
- DesignerOptionService.cs
- CheckableControlBaseAdapter.cs
- WindowsFormsHostPropertyMap.cs
- WaitingCursor.cs
- XmlEntity.cs
- XPathExpr.cs
- OleDbPermission.cs
- ClipboardProcessor.cs
- ChildTable.cs
- AutoResizedEvent.cs
- DataServiceQueryOfT.cs
- OleDbEnumerator.cs
- AnnotationDocumentPaginator.cs
- SafeNativeMemoryHandle.cs
- CustomGrammar.cs
- SafeNativeMemoryHandle.cs
- DataDocumentXPathNavigator.cs
- TableCellCollection.cs
- StringUtil.cs
- AstTree.cs
- XmlSerializerSection.cs
- ETagAttribute.cs
- SoapSchemaImporter.cs
- AlgoModule.cs
- TimeSpan.cs
- GridSplitterAutomationPeer.cs
- Separator.cs
- LinqDataSourceUpdateEventArgs.cs
- DescendantOverDescendantQuery.cs
- LeaseManager.cs
- TagPrefixAttribute.cs
- PreviewControlDesigner.cs
- SolidBrush.cs
- PrinterUnitConvert.cs
- WorkflowServiceOperationListItem.cs
- CaseInsensitiveComparer.cs
- WebPartDescription.cs
- CodeSubDirectory.cs
- IOThreadTimer.cs
- XmlILIndex.cs
- Effect.cs
- TimeStampChecker.cs
- TextInfo.cs
- HttpConfigurationContext.cs
- DockPanel.cs
- DataGridViewColumnHeaderCell.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- DifferencingCollection.cs
- IgnoreFlushAndCloseStream.cs
- HtmlControlAdapter.cs
- SignedXmlDebugLog.cs
- MessageDispatch.cs
- SchemaEntity.cs
- KeyFrames.cs
- RegistryKey.cs
- TargetInvocationException.cs
- AnnotationObservableCollection.cs
- DirectoryObjectSecurity.cs
- FormViewPagerRow.cs
- PropertyChangeTracker.cs
- HttpCapabilitiesSectionHandler.cs
- cryptoapiTransform.cs
- Random.cs
- ContractsBCL.cs
- PolyBezierSegment.cs
- JobInputBins.cs
- ContentIterators.cs
- Int32Collection.cs
- FrameworkRichTextComposition.cs
- CryptoConfig.cs
- EdmConstants.cs
- Rules.cs
- XmlCDATASection.cs
- CodeAccessPermission.cs
- DbMetaDataCollectionNames.cs
- SubMenuStyle.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- TraceContext.cs
- ConfigurationSettings.cs
- NameValueSectionHandler.cs
- PageRouteHandler.cs
- CodeParameterDeclarationExpression.cs
- CachedBitmap.cs
- ApplyImportsAction.cs
- RtType.cs
- SQLInt16.cs