Need application working for timer basis
-
Hi All, I create one sample win32 console application, which that application working for timer basis. Example : If the user gives the stared work is 1:00 AM and End Work is 3:30 AM and the current time is 1:30 AM then application will be in active till 3:30 AM. It automatically goes to idle state, if the system time crosses the end time that have been configured. The application will start again with in the timeframe on next day and so on. how to achieve this application using threading please share your valuable thoughts Thanks n advance Raju K
:~ Failure is Success If we learn from it!!:~
-
Hi All, I create one sample win32 console application, which that application working for timer basis. Example : If the user gives the stared work is 1:00 AM and End Work is 3:30 AM and the current time is 1:30 AM then application will be in active till 3:30 AM. It automatically goes to idle state, if the system time crosses the end time that have been configured. The application will start again with in the timeframe on next day and so on. how to achieve this application using threading please share your valuable thoughts Thanks n advance Raju K
:~ Failure is Success If we learn from it!!:~
Cannot you just use a timer (see"Using Timers"[^]) for the purpose? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi All, I create one sample win32 console application, which that application working for timer basis. Example : If the user gives the stared work is 1:00 AM and End Work is 3:30 AM and the current time is 1:30 AM then application will be in active till 3:30 AM. It automatically goes to idle state, if the system time crosses the end time that have been configured. The application will start again with in the timeframe on next day and so on. how to achieve this application using threading please share your valuable thoughts Thanks n advance Raju K
:~ Failure is Success If we learn from it!!:~
I will give you only some leads and not spoon feed you. What you have to do is something like this.
HANDLE hEvent;
long FunctionThread(void*)
{
while(true)
{
WaitForSingleObject(hEvent, NULL);
// do your job
// break out of this loop as necessary
}
return 0;
}long TimerCheckThread(void*)
{
while(true)
{
if(timeout)
{
SetEvent(hEvent);
}
// break out of this loop as necessary
}
return 0;
}void Setup()
{
// create the event
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);// start both the threads using CreateThread(...)
}
Event is something that allows synchronization of threads. WaitForSingleObject(...) function waits until the event is set and won't consume valuable CPU cycles. So, that job is going to start only after the time out has occurred. Read more about the terms that you encounter here and after you understand, you can easily build on this example.
...byte till it megahertz...