Click here to Skip to main content
15,911,715 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
HEllo,I need a loop that will make my program execute every 10 seconds but I have no idea how to do that...please help
Posted
Comments
[no name] 2-May-13 9:02am    
Why are you not using a timer for that?

1 solution

Create a "master" thread with a sleep timer or a time out for 10 seconds. This thread should only start another "worker" thread which will do the work.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-May-13 9:55am    
Right, a 5. However, OP asks about a "program". That said, OP can be recommended not to make it a program, but a program can also be started with System.Diagnostics.Process.Start (which I think is heavily abused, judging by frequent CodeProject questions).
—SA
KarstenK 3-May-13 2:08am    
if it is "his program" he should consider making into my "worker thread concept". This is the best way.

If it is an external program he should start it with the "master thread". Bad solution, because every 10 seconds an new environment for the program gets allocated. The dll overhead an some system stuff are slowing the overall performance and are a source of some errors.
Sergey Alexandrovich Kryukov 3-May-13 10:38am    
Sure.
—SA

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