private void ShutdownThisAppDomainOnce() { bool proceed = false; if (!_appDomainShutdownStarted) { lock (this) { if (!_appDomainShutdownStarted) { proceed = true; _appDomainShutdownStarted = true; } } } if (!proceed) return; Debug.Trace("AppManager", "HostingEnvironment - shutting down AppDomain, appId=" + _appId); // stop the timer used for idle timeout if (_idleTimeoutMonitor != null) { _idleTimeoutMonitor.Stop(); _idleTimeoutMonitor = null; } while (_inTrimCache == 1) { Thread.Sleep(100); } // close all outstanding WebSocket connections and begin winding down code that consumes them AspNetWebSocketManager.Current.AbortAllAndWait(); // HttpRuntime.SetUserForcedShutdown(); //WOS 1400290: CantUnloadAppDomainException in ISAPI mode, wait until HostingEnvironment.ShutdownThisAppDomainOnce completes _shutdownInProgress = false; HttpRuntime.ShutdownAppDomainWithStackTrace(ApplicationShutdownReason.HostingEnvironment, SR.GetString(SR.Hosting_Env_Restart), _shutDownStack); }
private void StartMonitoringForIdleTimeout() { HostingEnvironmentSection hostingEnvironment = RuntimeConfig.GetAppLKGConfig().HostingEnvironment; TimeSpan timeout = (hostingEnvironment != null) ? hostingEnvironment.IdleTimeout : HostingEnvironmentSection.DefaultIdleTimeout; this._idleTimeoutMonitor = new IdleTimeoutMonitor(timeout); }
private void StartMonitoringForIdleTimeout() { HostingEnvironmentSection hostEnvConfig = RuntimeConfig.GetAppLKGConfig().HostingEnvironment; TimeSpan idleTimeout = (hostEnvConfig != null) ? hostEnvConfig.IdleTimeout : HostingEnvironmentSection.DefaultIdleTimeout; // always create IdleTimeoutMonitor (even if config value is TimeSpan.MaxValue (infinite) // IdleTimeoutMonitor is also needed to keep the last event for app domain set trimming // and the timer is used to trim the application instances _idleTimeoutMonitor = new IdleTimeoutMonitor(idleTimeout); }
private void ShutdownThisAppDomainOnce() { bool flag = false; if (!this._appDomainShutdownStarted) { lock (this) { if (!this._appDomainShutdownStarted) { flag = true; this._appDomainShutdownStarted = true; } } } if (flag) { if (this._idleTimeoutMonitor != null) { this._idleTimeoutMonitor.Stop(); this._idleTimeoutMonitor = null; } while (this._inTrimCache == 1) { Thread.Sleep(100); } HttpRuntime.SetUserForcedShutdown(); this._shutdownInProgress = false; HttpRuntime.ShutdownAppDomainWithStackTrace(ApplicationShutdownReason.HostingEnvironment, System.Web.SR.GetString("Hosting_Env_Restart"), this._shutDownStack); } }