Example #1
0
        private void ShutdownThisAppDomainOnce()
        {
            bool shutdown = false;

            if (!_appDomainShutdownStarted)
            {
                lock (this)
                {
                    if (!_appDomainShutdownStarted)
                    {
                        shutdown = true;
                        _appDomainShutdownStarted = true;
                    }
                }
            }
            if (shutdown)
            {
                FluorineRuntime.SetUserForcedShutdown();
                _shutdownInProgress = false;
                FluorineRuntime.ShutdownAppDomain(ApplicationShutdownReason.HostingEnvironment, SR.GetString(SR.HostingEnvRestart));
            }
        }
        private void OnFileChanged(object sender, FileSystemEventArgs args)
        {
            lock (((ICollection)_watchers).SyncRoot)
            {
                if (_appShutdown)
                {
                    return;
                }
                Stop(false);

                // Disable event raising to avoid concurrent restarts
                DisableWatchers();

                ApplicationShutdownReason reason = ApplicationShutdownReason.None;
                string name    = new DirectoryInfo(args.FullPath).Name;
                string message = name + " dir change or directory rename";
                if (StringUtil.EqualsIgnoreCase(name, "web.config"))
                {
                    reason  = ApplicationShutdownReason.ConfigurationChange;
                    message = "Config file change";
                }
                else if (StringUtil.EqualsIgnoreCase(name, "bin"))
                {
                    reason = ApplicationShutdownReason.BinDirChangeOrDirectoryRename;
                }
                else
                {
                    reason = ApplicationShutdownReason.ConfigurationChange;
                }
                if (args.ChangeType == WatcherChangeTypes.Created)
                {
                    FluorineRuntime.SetUserForcedShutdown();
                }
                // Restart application
                FluorineRuntime.ShutdownAppDomain(reason, message);
            }
        }