C# 重新启动程序

private void Restart()
        {
            Thread thtmp = new Thread(new ParameterizedThreadStart(run));
            object appName = Application.ExecutablePath;
            Thread.Sleep(2000);
            thtmp.Start(appName);
        }

        private void run(Object obj)
        {
            Process ps = new Process();
            ps.StartInfo.FileName = obj.ToString();
            ps.Start();
        }

        /// <summary>
        /// 设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfig_Click(object sender, EventArgs e)
        {
            frmHikClientConfig frm = new frmHikClientConfig();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                Application.ExitThread();
                Restart();
            }
        }
posted @ 2008-10-30 14:07  zhh  阅读(925)  评论(0编辑  收藏  举报