Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Runtime / Remoting / LeaseManager.cs / 1305376 / 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; } [System.Security.SecurityCritical] // auto-generated 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; } [System.Security.SecurityCritical] // auto-generated 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; } [System.Security.SecurityCritical] // auto-generated 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; } [System.Security.SecurityCritical] // auto-generated 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
- UITypeEditor.cs
- DataRowCollection.cs
- DocumentViewer.cs
- AlphabetConverter.cs
- ListBoxItemAutomationPeer.cs
- TypeDescriptionProvider.cs
- SystemTcpStatistics.cs
- SchemaExporter.cs
- Int16.cs
- AxHost.cs
- CacheEntry.cs
- SplitterPanel.cs
- PathGradientBrush.cs
- Point3D.cs
- VarInfo.cs
- Camera.cs
- SmtpTransport.cs
- OleDbParameter.cs
- Errors.cs
- SelectionEditor.cs
- ObjectListDesigner.cs
- Mapping.cs
- ListViewItemEventArgs.cs
- CqlQuery.cs
- CookieProtection.cs
- DataControlFieldCollection.cs
- AmbientProperties.cs
- HashRepartitionStream.cs
- EventListener.cs
- FocusWithinProperty.cs
- TokenBasedSet.cs
- WaitingCursor.cs
- IdentifierService.cs
- TypeResolver.cs
- AuthenticationModuleElementCollection.cs
- BidPrivateBase.cs
- TextSerializer.cs
- CompilerTypeWithParams.cs
- UniqueEventHelper.cs
- WebDisplayNameAttribute.cs
- DbUpdateCommandTree.cs
- InvariantComparer.cs
- RemotingService.cs
- ListControlBoundActionList.cs
- BitFlagsGenerator.cs
- SamlAuthenticationStatement.cs
- MsmqPoisonMessageException.cs
- RuntimeResourceSet.cs
- RecordBuilder.cs
- Method.cs
- TextElementCollectionHelper.cs
- Lasso.cs
- TextUtf8RawTextWriter.cs
- SyndicationDeserializer.cs
- SafeNativeMethods.cs
- ToolBarOverflowPanel.cs
- ManagementEventWatcher.cs
- ExportOptions.cs
- UiaCoreProviderApi.cs
- NonVisualControlAttribute.cs
- UInt64Storage.cs
- AncillaryOps.cs
- RecognitionResult.cs
- StyleReferenceConverter.cs
- EpmSyndicationContentDeSerializer.cs
- PostBackTrigger.cs
- ImageListStreamer.cs
- Style.cs
- WebServiceParameterData.cs
- NonBatchDirectoryCompiler.cs
- IntegerValidatorAttribute.cs
- AmbientProperties.cs
- Rotation3DKeyFrameCollection.cs
- EnumCodeDomSerializer.cs
- GPPOINT.cs
- RijndaelManaged.cs
- ReferenceList.cs
- XmlChoiceIdentifierAttribute.cs
- CompressStream.cs
- UnaryNode.cs
- Queue.cs
- EntitySqlQueryState.cs
- OrderByLifter.cs
- SafeProcessHandle.cs
- StoreContentChangedEventArgs.cs
- XmlBufferReader.cs
- WindowsAuthenticationEventArgs.cs
- TraceUtils.cs
- GenericWebPart.cs
- XhtmlBasicCalendarAdapter.cs
- GCHandleCookieTable.cs
- RealProxy.cs
- PeerNameRecordCollection.cs
- PageRanges.cs
- GestureRecognizer.cs
- Perspective.cs
- OdbcTransaction.cs
- SqlClientWrapperSmiStreamChars.cs
- Convert.cs
- ResourcesGenerator.cs