好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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();

     }

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

以上这篇c#中实现退出程序后自动重新启动程序的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

dy("nrwz");

查看更多关于c#中实现退出程序后自动重新启动程序的方法的详细内容...

  阅读:90次