Restarting an application - how?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a problem I can't find a solution for. I have given my users the
ability to
restart the application from the File menu. I don't know how to re-invoke the
sub main() in my .vb module -- in the sub main, I do the following:

Dim frmSignon As New frmSignon
frmSignon.ShowDialog()
Application.Run(New frmMain)

First, am I invoking my application properly (I call the frmSignon first,
and if that's
successful, I then run the main application screen) and second, how do I
re-invoke
the application from within the main screen? I tried:

Application.Exit
Dim frmSignon As New frmSignon
frmSignon.ShowDialog()
Application.Run(New frmMain)

which upset the program terribly and it crashed. Any help is appreciated.
I'm at a
loss on this.

TIA,

W
 
I have a problem I can't find a solution for. I have given my users the
ability to
restart the application from the File menu. I don't know how to re-invoke the
sub main() in my .vb module -- in the sub main, I do the following:

Do not reinvoke your main but instead use the Process class to simply
launch a second instance of your application. You will need to pass the
path of your application's executable which is Application.ExecutablePath.
Once you've done that, close the current isntance with Application.Exit
 
Elp --

Thank you - that sort of helps. I'm in the development environment at this
point and really need to exit and restart the app. I'm assuming I can't just
do this with application.rundialog()?
 
Elp --

Thank you - that sort of helps. I'm in the development environment at this
point and really need to exit and restart the app. I'm assuming I can't just
do this with application.rundialog()?

Mmm, sorry i don't really understand what you are trying to say. What do
you mean by "I'm in the development environment at this point and really
need to exit and restart the app"?

To clarify what i said in my previous post, whenever you want to start
again your application from your application itself, use this code:

System.Diagnostics.Process.Start(Application.ExecutablePath)

After having executed this line of code you should have 2 instances of your
application running. Now if you want to restart your application from the
application itself (that is, close the current instance and launch a new
one), use the line of code above to launch a new instance of your app and
then use this code to close the current instance:

Application.Exit()
 
Back
Top