• 0

[C#] Process with delay


Question

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

  • 0

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?

  • 0

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.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.