Example #1
0
 private void TimerCompletionCallback(object state)
 {
     HttpApplicationFactory.TrimApplicationInstances();
     if (((((this._idleTimeout != TimeSpan.MaxValue) && !HostingEnvironment.ShutdownInitiated) && (HostingEnvironment.BusyCount == 0)) && (DateTime.UtcNow > this.LastEvent.Add(this._idleTimeout))) && !Debugger.IsAttached)
     {
         HttpRuntime.SetShutdownReason(ApplicationShutdownReason.IdleTimeout, System.Web.SR.GetString("Hosting_Env_IdleTimeout"));
         HostingEnvironment.InitiateShutdownWithoutDemand();
     }
 }
Example #2
0
        private void TimerCompletionCallback(Object state)
        {
            // user idle timer to trim the free list of app instanced
            HttpApplicationFactory.TrimApplicationInstances();

            // no idle timeout
            if (_idleTimeout == TimeSpan.MaxValue)
            {
                return;
            }

            // don't do idle timeout if already shutting down
            if (HostingEnvironment.ShutdownInitiated)
            {
                return;
            }

            // check if there are active requests
            if (HostingEnvironment.BusyCount != 0)
            {
                return;
            }

            // check if enough time passed
            if (DateTime.UtcNow <= LastEvent.Add(_idleTimeout))
            {
                return;
            }

            // check if debugger is attached
            if (System.Diagnostics.Debugger.IsAttached)
            {
                return;
            }

            // shutdown
            HttpRuntime.SetShutdownReason(ApplicationShutdownReason.IdleTimeout,
                                          SR.GetString(SR.Hosting_Env_IdleTimeout));
            HostingEnvironment.InitiateShutdownWithoutDemand();
        }