internal void SponsorCall(ISponsor sponsor) { bool flag = false; if (this.state == LeaseState.Expired) { return; } lock (this.sponsorTable) { try { object local_3 = this.GetSponsorId(sponsor); this.sponsorCallThread = Thread.CurrentThread.GetHashCode(); Lease.AsyncRenewal local_4 = new Lease.AsyncRenewal(sponsor.Renewal); Lease.SponsorStateInfo temp_22 = (Lease.SponsorStateInfo) this.sponsorTable[local_3]; int temp_23 = 1; temp_22.sponsorState = (Lease.SponsorState)temp_23; local_4.BeginInvoke((ILease)this, new AsyncCallback(this.SponsorCallback), (object)null); if (temp_22.sponsorState == Lease.SponsorState.Waiting && this.state != LeaseState.Expired) { this.leaseManager.RegisterSponsorCall(this, local_3, this.sponsorshipTimeout); } this.sponsorCallThread = 0; } catch (Exception exception_0) { flag = true; this.sponsorCallThread = 0; } } if (!flag) { return; } this.Unregister(sponsor); this.ProcessNextSponsor(); }
internal void SponsorCall(ISponsor sponsor) { bool flag = false; if (this.state == LeaseState.Expired) { return; } Hashtable obj = this.sponsorTable; lock (obj) { try { object sponsorId = this.GetSponsorId(sponsor); this.sponsorCallThread = Thread.CurrentThread.GetHashCode(); Lease.AsyncRenewal asyncRenewal = new Lease.AsyncRenewal(sponsor.Renewal); Lease.SponsorStateInfo sponsorStateInfo = (Lease.SponsorStateInfo) this.sponsorTable[sponsorId]; sponsorStateInfo.sponsorState = Lease.SponsorState.Waiting; IAsyncResult asyncResult = asyncRenewal.BeginInvoke(this, new AsyncCallback(this.SponsorCallback), null); if (sponsorStateInfo.sponsorState == Lease.SponsorState.Waiting && this.state != LeaseState.Expired) { this.leaseManager.RegisterSponsorCall(this, sponsorId, this.sponsorshipTimeout); } this.sponsorCallThread = 0; } catch (Exception) { flag = true; this.sponsorCallThread = 0; } } if (flag) { this.Unregister(sponsor); this.ProcessNextSponsor(); } }
internal void SponsorCallback(IAsyncResult iar) { if (this.state == LeaseState.Expired) { return; } if (Thread.CurrentThread.GetHashCode() == this.sponsorCallThread) { ThreadPool.QueueUserWorkItem(new WaitCallback(this.SponsorCallback), (object)iar); } else { Lease.AsyncRenewal asyncRenewal = (Lease.AsyncRenewal)((AsyncResult)iar).AsyncDelegate; ISponsor sponsor = (ISponsor)asyncRenewal.Target; Lease.SponsorStateInfo sponsorStateInfo = (Lease.SponsorStateInfo)null; if (iar.IsCompleted) { bool flag = false; TimeSpan timeSpan = TimeSpan.Zero; try { timeSpan = asyncRenewal.EndInvoke(iar); } catch (Exception ex) { flag = true; } if (flag) { this.Unregister(sponsor); this.ProcessNextSponsor(); } else { object sponsorId = this.GetSponsorId(sponsor); lock (this.sponsorTable) { if (this.sponsorTable.ContainsKey(sponsorId)) { sponsorStateInfo = (Lease.SponsorStateInfo) this.sponsorTable[sponsorId]; sponsorStateInfo.sponsorState = Lease.SponsorState.Completed; sponsorStateInfo.renewalTime = timeSpan; } } if (sponsorStateInfo == null) { this.ProcessNextSponsor(); } else if (sponsorStateInfo.renewalTime == TimeSpan.Zero) { this.Unregister(sponsor); this.ProcessNextSponsor(); } else { this.RenewInternal(sponsorStateInfo.renewalTime); } } } else { this.Unregister(sponsor); this.ProcessNextSponsor(); } } }
internal void SponsorCallback(IAsyncResult iar) { if (this.state == LeaseState.Expired) { return; } int hashCode = Thread.CurrentThread.GetHashCode(); if (hashCode == this.sponsorCallThread) { WaitCallback callBack = new WaitCallback(this.SponsorCallback); ThreadPool.QueueUserWorkItem(callBack, iar); return; } AsyncResult asyncResult = (AsyncResult)iar; Lease.AsyncRenewal asyncRenewal = (Lease.AsyncRenewal)asyncResult.AsyncDelegate; ISponsor sponsor = (ISponsor)asyncRenewal.Target; Lease.SponsorStateInfo sponsorStateInfo = null; if (!iar.IsCompleted) { this.Unregister(sponsor); this.ProcessNextSponsor(); return; } bool flag = false; TimeSpan renewalTime = TimeSpan.Zero; try { renewalTime = asyncRenewal.EndInvoke(iar); } catch (Exception) { flag = true; } if (flag) { this.Unregister(sponsor); this.ProcessNextSponsor(); return; } object sponsorId = this.GetSponsorId(sponsor); Hashtable obj = this.sponsorTable; lock (obj) { if (this.sponsorTable.ContainsKey(sponsorId)) { sponsorStateInfo = (Lease.SponsorStateInfo) this.sponsorTable[sponsorId]; sponsorStateInfo.sponsorState = Lease.SponsorState.Completed; sponsorStateInfo.renewalTime = renewalTime; } } if (sponsorStateInfo == null) { this.ProcessNextSponsor(); return; } if (sponsorStateInfo.renewalTime == TimeSpan.Zero) { this.Unregister(sponsor); this.ProcessNextSponsor(); return; } this.RenewInternal(sponsorStateInfo.renewalTime); }