private LeaseExpired ( System.DateTime now ) : void | ||
now | System.DateTime | |
Результат | void |
private void LeaseTimeAnalyzer(object state) { DateTime utcNow = DateTime.UtcNow; lock (this.leaseToTimeTable) { IDictionaryEnumerator local_3 = this.leaseToTimeTable.GetEnumerator(); while (local_3.MoveNext()) { DateTime local_4 = (DateTime)local_3.Value; Lease local_5 = (Lease)local_3.Key; if (local_4.CompareTo(utcNow) < 0) { this.tempObjects.Add((object)local_5); } } for (int local_6 = 0; local_6 < this.tempObjects.Count; ++local_6) { this.leaseToTimeTable.Remove((object)(Lease)this.tempObjects[local_6]); } } for (int index = 0; index < this.tempObjects.Count; ++index) { Lease lease = (Lease)this.tempObjects[index]; if (lease != null) { lease.LeaseExpired(utcNow); } } this.tempObjects.Clear(); lock (this.sponsorTable) { IDictionaryEnumerator local_10 = this.sponsorTable.GetEnumerator(); while (local_10.MoveNext()) { object temp_72 = local_10.Key; LeaseManager.SponsorInfo local_11 = (LeaseManager.SponsorInfo)local_10.Value; if (local_11.sponsorWaitTime.CompareTo(utcNow) < 0) { this.tempObjects.Add((object)local_11); } } for (int local_12 = 0; local_12 < this.tempObjects.Count; ++local_12) { this.sponsorTable.Remove(((LeaseManager.SponsorInfo) this.tempObjects[local_12]).sponsorId); } } for (int index = 0; index < this.tempObjects.Count; ++index) { LeaseManager.SponsorInfo sponsorInfo = (LeaseManager.SponsorInfo) this.tempObjects[index]; if (sponsorInfo != null && sponsorInfo.lease != null) { sponsorInfo.lease.SponsorTimeout(sponsorInfo.sponsorId); this.tempObjects[index] = (object)null; } } this.tempObjects.Clear(); this.leaseTimer.Change((int)this.pollTime.TotalMilliseconds, -1); }
// Thread Loop private void LeaseTimeAnalyzer(Object state) { //BCLDebug.Trace("REMOTE","LeaseManager LeaseTimeAnalyzer Entry ",state); // Find expired leases DateTime now = DateTime.Now; lock (leaseToTimeTable) { IDictionaryEnumerator e = leaseToTimeTable.GetEnumerator(); while (e.MoveNext()) { DateTime time = (DateTime)e.Value; Lease lease = (Lease)e.Key; //BCLDebug.Trace("REMOTE","LeaseManager LeaseTimeAnalyzer lease ",lease.id, " lease time ", time, " now ", now); if (time.CompareTo(now) < 0) { // lease expired tempObjects.Add(lease); } } for (int i = 0; i < tempObjects.Count; i++) { Lease lease = (Lease)tempObjects[i]; //BCLDebug.Trace("REMOTE","LeaseManager LeaseTimeAnalyzer lease Expired remove from leaseToTimeTable ",lease.id); leaseToTimeTable.Remove(lease); } } // Need to run this without lock on leaseToTimeTable to avoid deadlock for (int i = 0; i < tempObjects.Count; i++) { Lease lease = (Lease)tempObjects[i]; //BCLDebug.Trace("REMOTE","LeaseManager LeaseTimeAnalyzer lease Expired ",lease.id); if (lease != null) // Lease could be deleted if there is more then one reference to the lease { lease.LeaseExpired(now); } } tempObjects.Clear(); lock (sponsorTable) { IDictionaryEnumerator e = sponsorTable.GetEnumerator(); while (e.MoveNext()) { // Check for SponshipTimeOuts Object sponsorId = e.Key; SponsorInfo sponsorInfo = (SponsorInfo)e.Value; //BCLDebug.Trace("REMOTE","LeaseManager LeaseTimeAnalyzer sponsor time ", sponsorInfo.sponsorWaitTime, " now ", now); if (sponsorInfo.sponsorWaitTime.CompareTo(now) < 0) { // Sponsortimeout expired expired tempObjects.Add(sponsorInfo); } } // Process the timed out sponsors for (int i = 0; i < tempObjects.Count; i++) { SponsorInfo sponsorInfo = (SponsorInfo)tempObjects[i]; //BCLDebug.Trace("REMOTE","LeaseManager LeaseTimeAnalyzer sponsor Expired remove from spansorTable", sponsorInfo.sponsorId); sponsorTable.Remove(sponsorInfo.sponsorId); } } // Process the timed out sponsors // Need to run this without lock on sponsorTable to avoid deadlock for (int i = 0; i < tempObjects.Count; i++) { SponsorInfo sponsorInfo = (SponsorInfo)tempObjects[i]; //BCLDebug.Trace("REMOTE","LeaseManager LeaseTimeAnalyzer sponsor Expired ", sponsorInfo.sponsorId); if (sponsorInfo != null && sponsorInfo.lease != null) { sponsorInfo.lease.SponsorTimeout(sponsorInfo.sponsorId); } } tempObjects.Clear(); leaseTimer.Change((int)pollTime.TotalMilliseconds, Timeout.Infinite); //BCLDebug.Trace("REMOTE","LeaseManager LeaseTimeAnalyzer Exit"); }
private void LeaseTimeAnalyzer(object state) { DateTime utcNow = DateTime.UtcNow; lock (this.leaseToTimeTable) { IDictionaryEnumerator enumerator = this.leaseToTimeTable.GetEnumerator(); while (enumerator.MoveNext()) { DateTime time2 = (DateTime)enumerator.Value; Lease key = (Lease)enumerator.Key; if (time2.CompareTo(utcNow) < 0) { this.tempObjects.Add(key); } } for (int k = 0; k < this.tempObjects.Count; k++) { Lease lease2 = (Lease)this.tempObjects[k]; this.leaseToTimeTable.Remove(lease2); } } for (int i = 0; i < this.tempObjects.Count; i++) { Lease lease3 = (Lease)this.tempObjects[i]; if (lease3 != null) { lease3.LeaseExpired(utcNow); } } this.tempObjects.Clear(); lock (this.sponsorTable) { IDictionaryEnumerator enumerator2 = this.sponsorTable.GetEnumerator(); while (enumerator2.MoveNext()) { object obj1 = enumerator2.Key; SponsorInfo info = (SponsorInfo)enumerator2.Value; if (info.sponsorWaitTime.CompareTo(utcNow) < 0) { this.tempObjects.Add(info); } } for (int m = 0; m < this.tempObjects.Count; m++) { SponsorInfo info2 = (SponsorInfo)this.tempObjects[m]; this.sponsorTable.Remove(info2.sponsorId); } } for (int j = 0; j < this.tempObjects.Count; j++) { SponsorInfo info3 = (SponsorInfo)this.tempObjects[j]; if ((info3 != null) && (info3.lease != null)) { info3.lease.SponsorTimeout(info3.sponsorId); this.tempObjects[j] = null; } } this.tempObjects.Clear(); this.leaseTimer.Change((int)this.pollTime.TotalMilliseconds, -1); }
private void LeaseTimeAnalyzer(object state) { DateTime utcNow = DateTime.UtcNow; Hashtable obj = this.leaseToTimeTable; lock (obj) { IDictionaryEnumerator enumerator = this.leaseToTimeTable.GetEnumerator(); while (enumerator.MoveNext()) { DateTime dateTime = (DateTime)enumerator.Value; Lease value = (Lease)enumerator.Key; if (dateTime.CompareTo(utcNow) < 0) { this.tempObjects.Add(value); } } for (int i = 0; i < this.tempObjects.Count; i++) { Lease key = (Lease)this.tempObjects[i]; this.leaseToTimeTable.Remove(key); } } for (int j = 0; j < this.tempObjects.Count; j++) { Lease lease = (Lease)this.tempObjects[j]; if (lease != null) { lease.LeaseExpired(utcNow); } } this.tempObjects.Clear(); Hashtable obj2 = this.sponsorTable; lock (obj2) { IDictionaryEnumerator enumerator2 = this.sponsorTable.GetEnumerator(); while (enumerator2.MoveNext()) { object key2 = enumerator2.Key; LeaseManager.SponsorInfo sponsorInfo = (LeaseManager.SponsorInfo)enumerator2.Value; if (sponsorInfo.sponsorWaitTime.CompareTo(utcNow) < 0) { this.tempObjects.Add(sponsorInfo); } } for (int k = 0; k < this.tempObjects.Count; k++) { LeaseManager.SponsorInfo sponsorInfo2 = (LeaseManager.SponsorInfo) this.tempObjects[k]; this.sponsorTable.Remove(sponsorInfo2.sponsorId); } } for (int l = 0; l < this.tempObjects.Count; l++) { LeaseManager.SponsorInfo sponsorInfo3 = (LeaseManager.SponsorInfo) this.tempObjects[l]; if (sponsorInfo3 != null && sponsorInfo3.lease != null) { sponsorInfo3.lease.SponsorTimeout(sponsorInfo3.sponsorId); this.tempObjects[l] = null; } } this.tempObjects.Clear(); this.leaseTimer.Change((int)this.pollTime.TotalMilliseconds, -1); }