c#中实现退出程序后自动重新启动程序的示例代码分享

来源:这里教程网 时间:2026-02-21 13:42:36 作者:

下面小编就为大家带来一篇c#中实现退出程序后自动重新启动程序的方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

实例如下:

//触发退出程序事件
private void button1_Click(object sender, EventArgs e)
    {
       Application.ExitThread();
      Thread thtmp = new Thread(new ParameterizedThreadStart(run));
      object appName = Application.ExecutablePath;
      Thread.Sleep(1);
      thtmp.Start(appName);
    }
 private void run(Object obj)
    {
      Process ps = new Process();
      ps.StartInfo.FileName = obj.ToString();
      ps.Start();
    }

相关推荐