Click here to Skip to main content
15,917,320 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am looking for a wait function which will wait and stop the thread where it's running till specific system time (or when signaled).
for example, if the target time was set to 12:30, i'd like the program to run and the function to wait till 12:30, and then to wake up.

I've already found the WaitForSingleObject function but in this function you need to specifiy the waitting time in miliseconds...
in that case i have to calculate the time in milisec from now till the target time. this is my default choise for the moment..

Thanks!

Nir
Posted
Updated 3-Jan-10 23:08pm
v2

u can use "delay(int timeperiod)"
 
Share this answer
 
WaitForSingleObject is a good choice. What's the problem with milliseconds?
:)
 
Share this answer
 
How about AutoResetEvent.WaitOne(TimeSpan) ? You can create a TimeSpan object using the "-" operator on two DateTime objects. Thus, you can use something like:

AutoResetEvent^ m_event;
[...].
DateTime ^present = DateTime.Now; 
DateTime ^future = gcnew DateTime...
m_event->WaitOne(future - present);


Sorry this is only valid for C++/CLI
 
Share this answer
 
v2

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