Sample code sharing for automatically restarting a program after exiting it in c#

黄舟
Release: 2017-03-28 11:53:34
Original
2485 people have browsed it

The following editor will bring you a method to implement automatically restart the program after exiting the program in c#. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.

The examples are as follows:

//触发退出程序事件
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();
    }
Copy after login

The above is the detailed content of Sample code sharing for automatically restarting a program after exiting it in c#. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template