As I know Application.Restart()
restarts an application and creates new Instance of an Application. Does this instance will creates in new process, or old process will be used?
Thanks for an answer.
It runs in a new process. The documentation seems a little unclear on whether or not the process is reused but it can be verified by showing the process ID in a text box at start up.
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 see using .NET Reflector that a new process is created:
public static void Restart()
{
// ...
ExitInternal(); // Causes the application to exit.
Process.Start(startInfo); // Starts a new process.
// ...
}
According to the documentation it will start a new instance of the application and thus new process. If there were command line arguments supplied when starting the application those same arguments will be supplied to the new process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With