Hi,
I want to make a timer in my program, my program has to wait 5 seconds between making the calculation and showing an answer.
Can someone help me please:D?
Grtz
3 replies to this topic
#1
Posted 17 January 2011 - 11:27 AM
|
|
|
#2
Posted 17 January 2011 - 12:16 PM
Hello BramS, Welcome aboard!
You can put delay with sleep between the calculation and showing the answer like this:
But if you use that in a form or in main thread of GUI application, your program will not responding (appears like hung) for 5 seconds. So this solution is great only if you are doing it in separate thread in GUI application or in console application. For GUI application you may want to use TTimer component. Check the System tab in component palette.
Enable the TTimer at the end of calculation and in its OnTimer event show the answer. Do forget to disable the TTimer after you display the answer.
You can put delay with sleep between the calculation and showing the answer like this:
Answer := CalculateAnswer; Sleep(5000); ShowAnswer(Answer);
But if you use that in a form or in main thread of GUI application, your program will not responding (appears like hung) for 5 seconds. So this solution is great only if you are doing it in separate thread in GUI application or in console application. For GUI application you may want to use TTimer component. Check the System tab in component palette.
Enable the TTimer at the end of calculation and in its OnTimer event show the answer. Do forget to disable the TTimer after you display the answer.
#3
Posted 17 January 2011 - 12:42 PM
Thank you LuthfiHakim, this really helped me, my program works fine now :)
#4
Posted 17 January 2011 - 09:49 PM
Glad to be of help. Hope I will see you around :c-cool:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









