C#桌面软件程序重新启动

private void Restart()
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(obj =>
            {
                string exePath = Path.Combine(GlobalVariant.Root, "上课系统.exe");
                Process ps = new Process();
                ps.StartInfo.FileName = exePath;
                ps.StartInfo.Arguments = "restart";
                ps.Start();
            }));
        }


程序入口方法。

[STAThread]
        static void Main(string[] s)
        {
            bool createNew;
            using (System.Threading.Mutex m = new System.Threading.Mutex(true, Application.ProductName, out createNew))
            {
                if (s.Length == 1 && s[0] == "restart")
                {
                    Run();
                }
                else if (createNew)
                {
                    Run();
                }
            }
        }



猜你喜欢

转载自blog.csdn.net/wangzl1163/article/details/78437635