Пример #1
0
 internal SandboxedObject(IObject obj, ISponsor sponsor)
     : base(sponsor)
 {
     if (obj == null)
         throw new ArgumentException("Cannot instantiate an XObject with a null IObject.");
     _obj = obj;
     _touchListener = new OnTouchDelegate(TriggerTouch);
 }
Пример #2
0
        public void Unregister(ISponsor sponsor)
        {
            lock (this)
            {
                BCLDebug.Trace("REMOTE", "Lease", id, " Unregister  state ", ((Enum)state).ToString());
                if (state == LeaseState.Expired)
                {
                    return;
                }

                Object sponsorId = GetSponsorId(sponsor);
                lock (sponsorTable)
                {
                    if (sponsorId != null)
                    {
                        leaseManager.DeleteSponsor(sponsorId);
                        SponsorStateInfo sponsorStateInfo = (SponsorStateInfo)sponsorTable[sponsorId];
                        sponsorTable.Remove(sponsorId);
                    }
                }
            }
        }
Пример #3
0
        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();
            }
        }
Пример #4
0
        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();
        }
Пример #5
0
 public void Register(ISponsor obj, TimeSpan renewalTime)
 {
     lock (this)
     {
         if (this.state == LeaseState.Expired || this.sponsorshipTimeout == TimeSpan.Zero)
         {
             return;
         }
         object local_2 = this.GetSponsorId(obj);
         lock (this.sponsorTable)
         {
             if (renewalTime > TimeSpan.Zero)
             {
                 this.AddTime(renewalTime);
             }
             if (this.sponsorTable.ContainsKey(local_2))
             {
                 return;
             }
             this.sponsorTable[local_2] = (object)new Lease.SponsorStateInfo(renewalTime, Lease.SponsorState.Initial);
         }
     }
 }
Пример #6
0
 public LOParcel(Scene m_scene, int m_parcelID, ISponsor sponsor)
     : base(sponsor)
 {
     this.m_scene = m_scene;
     this.m_parcelID = m_parcelID;
 }
Пример #7
0
 public void TestInitialize()
 {
     _mockRepository = new MockRepository();
     _mockDomain = _mockRepository.StrictMock<ISponsor>();
 }
 private object GetSponsorId(ISponsor obj)
 {
     object obj2 = null;
     if (obj == null)
     {
         return obj2;
     }
     if (RemotingServices.IsTransparentProxy(obj))
     {
         return RemotingServices.GetRealProxy(obj);
     }
     return obj;
 }
Пример #9
0
        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);
        }
 public void Register(ISponsor obj)
 {
     this.Register(obj, TimeSpan.Zero);
 }
 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();
         }
     }
 }
Пример #12
0
 public void Unregister(ISponsor sponsor)
 {
     Console.WriteLine("The sponsor {0} has been unregistered from the current lease.", sponsor);
     baseLease.Unregister(sponsor);
 }
Пример #13
0
 public void Register(ISponsor obj, TimeSpan renewalTime)
 {
 }
Пример #14
0
 public Unloader(ISponsor sponsor)
     : base(sponsor)
 {
 }
 public SponsorController(IMethod _SMethod, IMinio _SMinio, ISponsor _SSponsor)
     : base(_SMethod)
 {
     this._SMinio   = _SMinio;
     this._SSponsor = _SSponsor;
 }
Пример #16
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or 
        /// resetting unmanaged resources.
        /// </summary>
        /// <param name="disposing"></param>
        private void Dispose(bool disposing)
        {
            lock (this)
            {
                if (_cacheStopped != null && !CacheType.Equals("mirror-server"))
                {
                    Delegate[] invocationList = this._cacheStopped.GetInvocationList();

                    foreach (Delegate subscriber in invocationList)
                    {
                        CacheStoppedCallback callback = (CacheStoppedCallback)subscriber;
                        try
                        {
                            callback(this._cacheInfo.Name, null);
                        }
                        catch (Exception e)
                        {
                            NCacheLog.Error("Cache.Dispose", "Error occurred while invoking cache stopped event: " + e.ToString());
                            //Ignore and move on to fire next
                        }
                        finally
                        {
                            this._cacheStopped -= callback;
                        }
                    }
                }

                try
                {
                    if (_inProc) RemotingServices.Disconnect(this);
                }
                catch (Exception) { }

                if (_context.CacheImpl != null)
                    _context.CacheImpl.StopServices();
                

               

               

                if (_connectedClients != null)
                    lock (_connectedClients.SyncRoot)
                    {
                        _connectedClients.Clear();
                    }

                _cacheStopped = null;
                _sponsor = null;

                if (NCacheLog != null)
                {
                    NCacheLog.CriticalInfo("Cache.Dispose", "Cache stopped successfully");
                    NCacheLog.Flush();
                    NCacheLog.Close();
                }


                try
                {
                    if (_channels != null) _channels.UnregisterTcpChannels();
                }
                catch (Exception) { }
                _channels = null;
                GC.Collect();

                if (disposing)
                {
                    GC.SuppressFinalize(this);
                }

                if (_context != null)
                {
                    _context.Dispose();
                }

                //Dispose snaphot pool for this cache.
                if (disposing)
                {
                    CacheSnapshotPool.Instance.DisposePool(_context.CacheRoot.Name);
                }

            }
        }
Пример #17
0
		public void Unregister (ISponsor obj)
		{
			lock (this) {
				if (_sponsors == null) return;
				
				// Don't use ArrayList.Remove() here because it will end calling Equals, which may
				// crash if the sponsor is not available anymore
				for (int n=0; n < _sponsors.Count; n++) {
					if (object.ReferenceEquals (_sponsors [n], obj)) {
						_sponsors.RemoveAt (n);
						break;
					}
				}
			}
		}
Пример #18
0
		public void Register (ISponsor obj, TimeSpan renewalTime)
		{
			lock (this) {
				if (_sponsors == null)
					_sponsors = new ArrayList();
				_sponsors.Add (obj);
			}

			if (renewalTime != TimeSpan.Zero)
				Renew (renewalTime);
		}
Пример #19
0
 public void Unregister(ISponsor obj)
 {
 }
Пример #20
0
 public void Register(ISponsor obj)
 {
 }
Пример #21
0
 public void Register(ISponsor obj)
 {
     throw new NotImplementedException();
 }
Пример #22
0
 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();
         }
     }
 }
Пример #23
0
 public void MyRegistration(ISponsor sponsor)
 {
     //Регистрируем у главного спонсора спонсор клиента
     _mainSponsor.AddSponsor(sponsor);
 }
Пример #24
0
 public SponsorService()
 {
     _sponsor = new StructureMapDependencyResolver().GetConcreteInstanceOf<ISponsor>();
 }
Пример #25
0
 public void Register(ISponsor obj)
 {
     Register(obj, TimeSpan.Zero);
 }
Пример #26
0
 internal SponsorService(ISponsor sponsor)
 {
     _sponsor = sponsor;
 }
		public void Unregister(ISponsor obj)
				{
					// TODO
				}
Пример #28
0
 public void MyRegistration(ISponsor sponsor)
 {
     _mainSponsor.AddSponsor(sponsor);
 }
 public void Register(ISponsor obj, TimeSpan renewalTime)
 {
     lock (this)
     {
         if ((this.state != LeaseState.Expired) && (this.sponsorshipTimeout != TimeSpan.Zero))
         {
             object sponsorId = this.GetSponsorId(obj);
             lock (this.sponsorTable)
             {
                 if (renewalTime > TimeSpan.Zero)
                 {
                     this.AddTime(renewalTime);
                 }
                 if (!this.sponsorTable.ContainsKey(sponsorId))
                 {
                     this.sponsorTable[sponsorId] = new SponsorStateInfo(renewalTime, SponsorState.Initial);
                 }
             }
         }
     }
 }
Пример #30
0
        // 需要让非默认AppDomain中的CrawlTask对象不断给默认AppDomain中的对象“续租时间”
        static void RegisterSponsor(object obj, ISponsor sponsor)
        {
            ILease lease = (ILease)((MarshalByRefObject)obj).GetLifetimeService();

            lease.Register(sponsor);
        }
 public void Unregister(ISponsor sponsor)
 {
     lock (this)
     {
         if (this.state != LeaseState.Expired)
         {
             object sponsorId = this.GetSponsorId(sponsor);
             lock (this.sponsorTable)
             {
                 if (sponsorId != null)
                 {
                     this.leaseManager.DeleteSponsor(sponsorId);
                     SponsorStateInfo info1 = (SponsorStateInfo) this.sponsorTable[sponsorId];
                     this.sponsorTable.Remove(sponsorId);
                 }
             }
         }
     }
 }
Пример #32
0
 public Graphics(Scene m_scene, ISponsor sponsor)
     : base(sponsor)
 {
     this.m_scene = m_scene;
 }
Пример #33
0
 public void AddSponsor(ISponsor sponsor)
 {
     _listSponsors.Add(sponsor);
 }
Пример #34
0
 public void Register(ISponsor obj, TimeSpan renewalTime)
 {
     throw new NotImplementedException();
 }
Пример #35
0
 public void AddSponsor(ISponsor sponsor)
 {
     _listSponsors.Add(sponsor);
 }
Пример #36
0
 public void Unregister(ISponsor obj)
 {
     throw new NotImplementedException();
 }
Пример #37
0
 public void TestCleanup()
 {
     _mockDomain = null;
 }
Пример #38
0
        public void Register(ISponsor obj, TimeSpan renewalTime)
        {
            lock(this)
            {
                BCLDebug.Trace("REMOTE", "Lease "+id+" Register Sponsor  renewalTime ",renewalTime," state ",((Enum)state).ToString());
                if (state == LeaseState.Expired || sponsorshipTimeout == TimeSpan.Zero)
                    return;

                Object sponsorId = GetSponsorId(obj);
                lock(sponsorTable)
                {
                    if (renewalTime > TimeSpan.Zero)
                        AddTime(renewalTime);
                    if (!sponsorTable.ContainsKey(sponsorId))
                    {
                        // Place in tables
                        sponsorTable[sponsorId] = new SponsorStateInfo(renewalTime, SponsorState.Initial);
                    }
                }
            }
        }
 public SponsorSchedule()
 {
     lockObject = new object();
     timer      = new Timer(SponsorTimerDoWork, lockObject, TimeSpan.Zero, TimeSpan.FromDays(1));
     _SSponsor  = new SSponsor(new DbContext());
 }
Пример #40
0
        public void Unregister(ISponsor sponsor)
        {
            lock(this)
            {
                BCLDebug.Trace("REMOTE", "Lease",id," Unregister  state ",((Enum)state).ToString());
                if (state == LeaseState.Expired)
                    return;

                Object sponsorId = GetSponsorId(sponsor);
                lock(sponsorTable)
                {
                    if (sponsorId != null)
                    {
                        leaseManager.DeleteSponsor(sponsorId);                
                        SponsorStateInfo sponsorStateInfo = (SponsorStateInfo)sponsorTable[sponsorId];
                        sponsorTable.Remove(sponsorId);
                    }
                }
            }
        }
Пример #41
0
 protected internal KillableProxyChild(ISponsor sponsor)
 {
     m_sponsor = sponsor;
 }
Пример #42
0
 [System.Security.SecurityCritical]  // auto-generated
 private Object GetSponsorId(ISponsor obj)
 {
     Object sponsorId = null;
     if (obj != null)
     {
         if (RemotingServices.IsTransparentProxy(obj))
             sponsorId = RemotingServices.GetRealProxy(obj);
         else
             sponsorId = obj;
     }
     return sponsorId;
 }
Пример #43
0
 public void Register(ISponsor obj, TimeSpan renewalTime)
 {
     throw new NotImplementedException();
 }
Пример #44
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();
            }
        }
Пример #45
0
 internal void SponsorCallback(IAsyncResult iar)
 {
     if (this.state != LeaseState.Expired)
     {
         if (Thread.CurrentThread.GetHashCode() == this.sponsorCallThread)
         {
             WaitCallback callBack = new WaitCallback(this.SponsorCallback);
             ThreadPool.QueueUserWorkItem(callBack, iar);
         }
         else
         {
             AsyncResult      result        = (AsyncResult)iar;
             AsyncRenewal     asyncDelegate = (AsyncRenewal)result.AsyncDelegate;
             ISponsor         target        = (ISponsor)asyncDelegate.Target;
             SponsorStateInfo info          = null;
             if (iar.IsCompleted)
             {
                 bool     flag = false;
                 TimeSpan zero = TimeSpan.Zero;
                 try
                 {
                     zero = asyncDelegate.EndInvoke(iar);
                 }
                 catch (Exception)
                 {
                     flag = true;
                 }
                 if (flag)
                 {
                     this.Unregister(target);
                     this.ProcessNextSponsor();
                 }
                 else
                 {
                     object sponsorId = this.GetSponsorId(target);
                     lock (this.sponsorTable)
                     {
                         if (this.sponsorTable.ContainsKey(sponsorId))
                         {
                             info = (SponsorStateInfo)this.sponsorTable[sponsorId];
                             info.sponsorState = SponsorState.Completed;
                             info.renewalTime  = zero;
                         }
                     }
                     if (info == null)
                     {
                         this.ProcessNextSponsor();
                     }
                     else if (info.renewalTime == TimeSpan.Zero)
                     {
                         this.Unregister(target);
                         this.ProcessNextSponsor();
                     }
                     else
                     {
                         this.RenewInternal(info.renewalTime);
                     }
                 }
             }
             else
             {
                 this.Unregister(target);
                 this.ProcessNextSponsor();
             }
         }
     }
 }
Пример #46
0
 public void MyRegistration(ISponsor sponsor)
 {
     _mainSponsor.AddSponsor(sponsor);
 }
Пример #47
0
 public void Register(ISponsor sponsor, TimeSpan renewalTime)
 {
     Console.WriteLine("The sponsor {0} has been registered with the current lease for {0} milliseconds...", sponsor, renewalTime.Milliseconds);
     baseLease.Register(sponsor, renewalTime);
 }
		public void Register(ISponsor obj)
				{
					Register(obj, new TimeSpan(0));
				}
Пример #49
0
 public void Register(ISponsor sponsor)
 {
     Console.WriteLine("The sponsor {0} has been registered with the current lease.", sponsor);
     baseLease.Register(sponsor);
 }
		public void Register(ISponsor obj, TimeSpan renewalTime)
				{
					// TODO
				}
Пример #51
0
        // On another thread
        internal void SponsorCallback(IAsyncResult iar)
        {
            BCLDebug.Trace("REMOTE", "Lease ", id, " SponsorCallback IAsyncResult ", iar, " state ", ((Enum)state).ToString());
            if (state == LeaseState.Expired)
            {
                return;
            }

            int thisThread = Thread.CurrentThread.GetHashCode();

            if (thisThread == sponsorCallThread)
            {
                WaitCallback threadFunc = new WaitCallback(this.SponsorCallback);
                ThreadPool.QueueUserWorkItem(threadFunc, iar);
                return;
            }

            AsyncResult      asyncResult      = (AsyncResult)iar;
            AsyncRenewal     ar               = (AsyncRenewal)asyncResult.AsyncDelegate;
            ISponsor         sponsor          = (ISponsor)ar.Target;
            SponsorStateInfo sponsorStateInfo = null;

            if (iar.IsCompleted)
            {
                // Sponsor came back with renewal
                BCLDebug.Trace("REMOTE", "Lease ", id, " SponsorCallback sponsor completed");
                bool     exceptionOccurred = false;
                TimeSpan renewalTime       = TimeSpan.Zero;
                try
                {
                    renewalTime = (TimeSpan)ar.EndInvoke(iar);
                }catch (Exception)
                {
                    // Sponsor not avaiable
                    exceptionOccurred = true;
                }
                if (exceptionOccurred)
                {
                    BCLDebug.Trace("REMOTE", "Lease ", id, " SponsorCallback Sponsor Exception ");
                    Unregister(sponsor);
                    ProcessNextSponsor();
                }
                else
                {
                    Object sponsorId = GetSponsorId(sponsor);
                    lock (sponsorTable)
                    {
                        if (sponsorTable.ContainsKey(sponsorId))
                        {
                            sponsorStateInfo = (SponsorStateInfo)sponsorTable[sponsorId];
                            sponsorStateInfo.sponsorState = SponsorState.Completed;
                            sponsorStateInfo.renewalTime  = renewalTime;
                        }
                        else
                        {
                            // Sponsor was deleted, possibly from a sponsor time out
                        }
                    }

                    if (sponsorStateInfo == null)
                    {
                        // Sponsor was deleted
                        ProcessNextSponsor();
                    }
                    else if (sponsorStateInfo.renewalTime == TimeSpan.Zero)
                    {
                        BCLDebug.Trace("REMOTE", "Lease ", id, " SponsorCallback sponsor did not renew ");
                        Unregister(sponsor);
                        ProcessNextSponsor();
                    }
                    else
                    {
                        Renew(sponsorStateInfo.renewalTime);
                    }
                }
            }
            else
            {
                // Sponsor timed out
                // Note time outs should be handled by the LeaseManager
                BCLDebug.Trace("REMOTE", "Lease ", id, " SponsorCallback sponsor did not complete, timed out");
                Unregister(sponsor);
                ProcessNextSponsor();
            }
        }
Пример #52
0
 public void Register(ISponsor obj)
 {
     Register(obj, new TimeSpan(0));
 }