Hi!
How to make a function wait for x seconds before doing something??
Example: When I click a button: in the onmousedown, I want to wait 1 second before it executes a function
Thank you
Sleep(number of milliseconds to wait)
suspends the execution of your program.
Or you use a TimerComponent and with your mousedownevent you enable the timer (Timer->Enabled=true)
In your TimerEvent (Timer->OnTimer)you first set the Timer->Enabled to false (otherwise you keep on triggering your event) and then you put the code you want to execute after 1 second.
Personally I would prefer the second solution, in a windows environment I find it a bit tricky to really suspend the execution of a program,but it works.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.