Exemplo n.º 1
0
        public static void RestartMP()
        {
            bool hideTaskBar = false;

            using (Settings xmlreader = new MPSettings())
            {
                hideTaskBar = xmlreader.GetValueAsBool("general", "hidetaskbar", false);
            }

            if (hideTaskBar)
            {
                Win32API.EnableStartBar(true);
                Win32API.ShowStartBar(true);
            }

            Log.Info("argustv: OnRestart - prepare for restart!");
            File.Delete(Config.GetFile(Config.Dir.Config, "mediaportal.running"));
            Log.Info("argustv: OnRestart - saving settings...");
            Settings.SaveCache();

            Log.Info("argustv: disposing databases.");
            FolderSettings.Dispose();
            PictureDatabase.Dispose();
            VideoDatabase.Dispose();
            MusicDatabase.Dispose();
            VolumeHandler.Dispose();

            System.Diagnostics.Process restartScript = new System.Diagnostics.Process();
            restartScript.EnableRaisingEvents        = false;
            restartScript.StartInfo.WorkingDirectory = Config.GetFolder(Config.Dir.Base);
            restartScript.StartInfo.FileName         = Config.GetFile(Config.Dir.Base, @"restart.vbs");
            Log.Debug("argustv: OnRestart - executing script {0}", restartScript.StartInfo.FileName);
            restartScript.Start();

            try
            {
                // Maybe the scripting host is not available therefore do not wait infinitely.
                if (!restartScript.HasExited)
                {
                    restartScript.WaitForExit();
                }
            }
            catch (Exception ex)
            {
                Log.Error("argustv: OnRestart - WaitForExit: {0}", ex.Message);
            }
        }