internal void SponsorCall(ISponsor sponsor)
        {
            bool flag = false;

            if (this.state != LeaseState.Expired)
            {
                lock (this.sponsorTable)
                {
                    try
                    {
                        object sponsorId = this.GetSponsorId(sponsor);
                        this.sponsorCallThread = Thread.CurrentThread.GetHashCode();
                        AsyncRenewal     renewal = new AsyncRenewal(sponsor.Renewal);
                        SponsorStateInfo info    = (SponsorStateInfo)this.sponsorTable[sponsorId];
                        info.sponsorState = SponsorState.Waiting;
                        renewal.BeginInvoke(this, new AsyncCallback(this.SponsorCallback), null);
                        if ((info.sponsorState == 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();
                }
            }
        }
Beispiel #2
0
        internal void SponsorCall(ISponsor sponsor)
        {
            BCLDebug.Trace("REMOTE", "Lease ", id, " SponsorCall state ", ((Enum)state).ToString());
            bool exceptionOccurred = false;

            if (state == LeaseState.Expired)
            {
                return;
            }

            lock (sponsorTable)
            {
                try
                {
                    Object sponsorId = GetSponsorId(sponsor);
                    sponsorCallThread = Thread.CurrentThread.GetHashCode();
                    AsyncRenewal     ar = new AsyncRenewal(sponsor.Renewal);
                    SponsorStateInfo sponsorStateInfo = (SponsorStateInfo)sponsorTable[sponsorId];
                    sponsorStateInfo.sponsorState = SponsorState.Waiting;

                    // The first parameter should be the lease we are trying to renew.
                    IAsyncResult iar = ar.BeginInvoke(this, new AsyncCallback(this.SponsorCallback), null);
                    if ((sponsorStateInfo.sponsorState == SponsorState.Waiting) && (state != LeaseState.Expired))
                    {
                        //   Even if we get here, the operation could still complete before
                        //   we call the the line below. This seems to be a race.

                        // Sponsor could have completed before statement is reached, so only execute
                        // if the sponsor state is still waiting
                        leaseManager.RegisterSponsorCall(this, sponsorId, sponsorshipTimeout);
                    }
                    sponsorCallThread = 0;
                }catch (Exception)
                {
                    // Sponsor not avaiable
                    exceptionOccurred = true;

                    sponsorCallThread = 0;
                }
            }

            if (exceptionOccurred)
            {
                BCLDebug.Trace("REMOTE", "Lease ", id, " SponsorCall Sponsor Exception ");
                Unregister(sponsor);
                ProcessNextSponsor();
            }
        }
 internal void SponsorCall(ISponsor sponsor)
 {
     bool flag = false;
     if (this.state != LeaseState.Expired)
     {
         lock (this.sponsorTable)
         {
             try
             {
                 object sponsorId = this.GetSponsorId(sponsor);
                 this.sponsorCallThread = Thread.CurrentThread.GetHashCode();
                 AsyncRenewal renewal = new AsyncRenewal(sponsor.Renewal);
                 SponsorStateInfo info = (SponsorStateInfo) this.sponsorTable[sponsorId];
                 info.sponsorState = SponsorState.Waiting;
                 renewal.BeginInvoke(this, new AsyncCallback(this.SponsorCallback), null);
                 if ((info.sponsorState == 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();
         }
     }
 }
Beispiel #4
0
        [System.Security.SecurityCritical]  // auto-generated
        internal void SponsorCall(ISponsor sponsor)
        {
            BCLDebug.Trace("REMOTE","Lease ",id," SponsorCall state ",((Enum)state).ToString());
            bool exceptionOccurred = false;
            if (state == LeaseState.Expired)
                return;

            lock(sponsorTable)
            {
                try
                {
                    Object sponsorId = GetSponsorId(sponsor);            
                    sponsorCallThread = Thread.CurrentThread.GetHashCode();
                    AsyncRenewal ar = new AsyncRenewal(sponsor.Renewal);
                    SponsorStateInfo sponsorStateInfo = (SponsorStateInfo)sponsorTable[sponsorId];            
                    sponsorStateInfo.sponsorState = SponsorState.Waiting;

                    // The first parameter should be the lease we are trying to renew.
                    IAsyncResult iar = ar.BeginInvoke(this, new AsyncCallback(this.SponsorCallback), null);
                    if ((sponsorStateInfo.sponsorState == SponsorState.Waiting) && (state != LeaseState.Expired))
                    {
                        //   Even if we get here, the operation could still complete before
                        //   we call the the line below. This seems to be a ----.
                        
                        // Sponsor could have completed before statement is reached, so only execute
                        // if the sponsor state is still waiting
                        leaseManager.RegisterSponsorCall(this, sponsorId, sponsorshipTimeout);
                    }
                    sponsorCallThread = 0;
                }catch(Exception)
                {
                    // Sponsor not avaiable
                    exceptionOccurred = true;

                    sponsorCallThread = 0;
                }
            }

            if (exceptionOccurred)
            {
                BCLDebug.Trace("REMOTE","Lease ",id," SponsorCall Sponsor Exception ");
                Unregister(sponsor);
                ProcessNextSponsor();
            }
        }