'Restart c# console app after executing succesfull
How to automatically restart c# console application after a succesfull run? My program should be running continuously. And i should be like a loop but not in the code cuz that doesn't work.
What i've tried:
Application.Restart();
Environment.Exit(0);
And
System.Environment.Restart();
None of these seems to work for my project. So i'm looking for other ways?
Solution 1:[1]
There's a similar issue here for restating a console application here How restart the Console app?
Essentially you ask to start the application again.
If it's just that you want to run the same functionality you could use a loop or similar.
var shouldExit = false;
while(!shouldExit)
{
// do work.
var result = MethodToDoWork();
// Get whether user wants to restart
if(!result.Success)
{
shouldExit = true;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | simlawstu |