borked technique Posted May 26, 2006 Share Posted May 26, 2006 In my code, I want to start a .exe file but I want to wait 30 seconds before the start of it. I thought of doing it like so: ProcessStartInfo startinfo = new ProcessStartInfo(); startinfo.FileName = "cmd.exe"; startinfo.Arguments = @"C:\program.exe"; startinfo.UseShellExecute = false; startinfo.CreateNoWindow = true; Process process; process = Process.Start(startinfo); This would work except I still need a delay. Any help? Thanks. Link to comment https://www.neowin.net/forum/topic/464492-c-process-with-delay/ Share on other sites More sharing options...
0 DaveLegg Developer Posted May 26, 2006 Developer Share Posted May 26, 2006 Add: Thread.Sleep(30000); and be sure to include the System.Threading namespace. Link to comment https://www.neowin.net/forum/topic/464492-c-process-with-delay/#findComment-587546145 Share on other sites More sharing options...
0 borked technique Posted May 26, 2006 Author Share Posted May 26, 2006 I need to clarify more. Thread.Sleep would work, except I have to make the call to start the program, and then my program has to die and be shutdown before this other process starts. I figure 30 seconds is enough time for it to do that. Is there a way to send a delay command in to the command prompt and then start my program? Link to comment https://www.neowin.net/forum/topic/464492-c-process-with-delay/#findComment-587546151 Share on other sites More sharing options...
0 Menge Posted May 26, 2006 Share Posted May 26, 2006 oh... you want to queue the start of the program OUTSIDE of yours... so that they startup command waits while yours shuts down? hmmm i doubt that's possible :\ Link to comment https://www.neowin.net/forum/topic/464492-c-process-with-delay/#findComment-587546157 Share on other sites More sharing options...
0 DaveLegg Developer Posted May 26, 2006 Developer Share Posted May 26, 2006 The only way I can think of doing that would be to write a second program that waits 30 seconds and loads the desired program, you call that program and close the first program, the second waits 30 seconds then loads the one you wanted to in the first place. Link to comment https://www.neowin.net/forum/topic/464492-c-process-with-delay/#findComment-587546162 Share on other sites More sharing options...
0 borked technique Posted May 26, 2006 Author Share Posted May 26, 2006 That's what I want to do... I could make a .cmd file and tell it to do the delay, but if I can do it another I would rather do that. Link to comment https://www.neowin.net/forum/topic/464492-c-process-with-delay/#findComment-587546164 Share on other sites More sharing options...
Question
borked technique
In my code, I want to start a .exe file but I want to wait 30 seconds before the start of it.
I thought of doing it like so:
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.FileName = "cmd.exe";
startinfo.Arguments = @"C:\program.exe";
startinfo.UseShellExecute = false;
startinfo.CreateNoWindow = true;
Process process;
process = Process.Start(startinfo);
This would work except I still need a delay. Any help? Thanks.
Link to comment
https://www.neowin.net/forum/topic/464492-c-process-with-delay/Share on other sites
5 answers to this question
Recommended Posts