Click here to Skip to main content
15,942,964 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to create button run 5 .exe files with delay time like after 3 sec run number 2 etc ... thanks

What I have tried:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
End Sub
Updated 17-Jan-20 8:48am

1 solution

Couple of ways:
1) Add Thread.Sleep(NumberOfSeconds * 1000) between each calls to Process.Start. This is bad - it freezes your UI while the Sleep goes on.
2) Set up a Timer for a 1/10th second interval and handle it's Tick event. Add counters to your app, one for each process you want to start.
In the Tick event, check each tcounter in turn.
If it's zero, do nothing and move on to the next timer.
Otherwise, reduce it by one. If it's now zero, start the process.

When you want to start the processes, just set the counters to the required interval: counter1 gets 1, counter2 gets 1 + 30, counter3 gets 1 + 30 + 30, and so on.
This takes a bit more coding, but it's more friendly for your user, and can be a lot more flexible as well.
Share this answer
Ahmed Adel 17-Jan-20 14:48pm    
Thread.Sleep(NumberOfSeconds * 1000)
that code not working i already tried that
ZurdoDev 17-Jan-20 16:52pm    
It does work so you'll need to be more specific and show the code that did not work.
OriginalGriff 17-Jan-20 17:00pm    
I'm guessing it ... froze the UI ... :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900