Reputation: 492
I have my C++ project, and I want an event to start 40 seconds after my form is loaded. I know there is a timer in C++, but it only shows intervals.
I'm using Visual Studio 2008. I'm creating a Windows Form Application. Do you guys know what function I have to use?
Upvotes: 1
Views: 1386
Reputation: 18492
Are you talking about the .NET Timer? Why doesn't it work for you? That link provides examples (assuming that's what you're talking about) of setting it up and then after it's gone off you can just dispose of it so your event doesn't start multiple times.
EDIT: The interval is in milliseconds, so just multiply your seconds amount by 1000. ie for 40 seconds, 40 * 1000 = 40000
.
EDIT2: As per your other comment, at the bottom of the link I provided is an example for C++. The TimerEventProcessor
is set as an EventHandler
for the timer in Main
and will be run when the the timer is "raised" (Visual Studio might already set that up for you when you add a Timer
control to the form). Since you only want the timer to run once and you don't need the other functionality it provides, I would simply choose to use a thread as I previously suggested:
You could also simply have another thread, which calls sleep
to wait for 40 seconds, and then starts your "event."
Upvotes: 1
Reputation: 3073
Setup the timer using a 40 seconds interval and remove the timer when it's first triggered.
Upvotes: 3