c#中实现退出程序后自动重新启动程序的方法

作者:袖梨 2022-06-25
 代码如下复制代码
//触发退出程序事件

privatevoidbutton1_Click(objectsender, EventArgs e)

    {

       Application.ExitThread();

      Thread thtmp =newThread(newParameterizedThreadStart(run));

      objectappName = Application.ExecutablePath;

      Thread.Sleep(1);

      thtmp.Start(appName);

    }

 privatevoidrun(Object obj)

    {

      Process ps =newProcess();

      ps.StartInfo.FileName = obj.ToString();

      ps.Start();

    }

 

注:Process 的命名空间为:System.Diagnostics;

相关文章

精彩推荐