Is it possible to do something like the following:
bool wasRestarted = ???;
main() {
if(wasRestarted) {
MessageBox.Show("Welcome Back John");
}
Application.Restart();
}
This is specifically to the Application.Restart and NOT soft closing and reopening.
Only way I can think of right now is by creating a Setting Value:
- Type: int
- Default: 0
Set it to 1 before restarting, then check for 1.
There has to be a better way then this?
Selected Answer worked perfect! As usual, thanks to the community for bringing a new feature to my brain :P
I used this to do a workaround for releasing a Mutex on Application.Restart on another thread. Since Mutex's are Thread Locked, I couldn't release a mutex on a login funtion before restarting, causing the Restart to return a locked mutex and couldnt continue. With this, I could know if it restarted, then do a simple while with a delay until the first "Application" actually closed and prematurely Program's Main() closed off resulting in the Mutex being cleared. The while() will then continue, and now my app works like normal!
Obviously for my needs, this wasn't the most ideal outcome, but it does work, and thats all I can ask for.