Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

restarting a program from itself

After the user finishes with the program I write, I want the program to restart automatically (it starts in a 'sleep' mode).
What is the best way to restart the program from it's own end?
Thanks.
0
gilbert_chang
Asked:
gilbert_chang
  • 2
1 Solution
 
TricksterCommented:
Is there any reason why you can't just include the main-code in a while-loop? For example using

int looping = 0;
while (looping == 0)
{
    PROGRAM!
    if (userWantsToQuit)
        looping = 1;
}

I often use a Timer which runs the program when I want the program to restart after a set number of seconds..

Trickster
0
 
ZoppoCommented:
At the end of your programm use something like

_spawnl( _P_NOWAIT, lpszAppFullPath, lpszAppFullPath, NULL );

hope that helps,

ZOPPO
0
 
gilbert_changAuthor Commented:
Trickster - what about threads and other memory structures I created in the program.
Trying to start them over might cuase explosions...right?
Thanks.
0
 
gilbert_changAuthor Commented:
Thanks Zoppo!
This works.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now