Does Application.Restart () create a new process for the application or not?

As I know, Application.Restart() restarts the application and creates a new instance of the application. Will this instance be created in a new process or will the old process be used?

Thanks for the answer.

+6
c #
source share
3 answers

It starts in a new process. The documentation seems a bit unclear about whether this process is being reused, but it can be checked by specifying the process ID in the text box at startup.

 public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Application.Restart(); } private void Form1_Load(object sender, EventArgs e) { textBox1.Text = Process.GetCurrentProcess().Id.ToString(); } } 

You can also use .NET Reflector to create a new process:

 public static void Restart() { // ... ExitInternal(); // Causes the application to exit. Process.Start(startInfo); // Starts a new process. // ... } 
+9
source share

According to the documentation , it will launch a new instance of the application and, therefore, a new process. If there were command line arguments when starting the application, the same arguments will be passed to the new process.

+4
source share

It launches a new instance. You may encounter a problem if, if your source application is still working with the workflow, the source process may not be killed soon enough so that in the end you will simultaneously start 2 instances (which will be shown in the task manager).

0
source share

All Articles