Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start a process after a certain time interval in C#?

Tags:

c#

I have a c# wpf application where in the main() method, I check for a certain condition and if it is true, I run a different process, however, I need to start the process after a certain timeout. So, for eg:

override OnStartUp()

    {
           if(condition == true)
           {
                ProcessStartInfo p = new ProcessStartInfo("filePath");
                p.Start(); // This should wait for like say 5 seconds and then start.
                  return;   // This will exit the current program.
            }
    }

I could use Thread.Sleep() but that will cause the current program to sleep as well. So, in other words, I want the current program to terminate immediately and then new process to start after 5 seconds.

Thanks!

Is this possible?

like image 985
user1202434 Avatar asked Feb 19 '23 01:02

user1202434


1 Answers

What if the first process creates a third program. The first program exits immediately, whilst the third one will simply sleep for 5 seconds and then will start your second program.

like image 108
Exulted Avatar answered Feb 21 '23 14:02

Exulted