Doing action every X hours

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
Juzbrig
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Jul 12, 2008 4:59 am

Doing action every X hours

Post by Juzbrig »

Hi
I am writing a program(WinXP, WxDev-cpp) that after button is pressed should do something and send it on email (i've done this), wait in idle X hours/minutes and do it again until 'stop' button is pressed.

Problem is I don't know how to sleep/idle the program. I tried
while(1==1){
Sleep(time)
//do something
}
but I just hang app, and CPU usage gone high during 'time'.
I thought wxThread could be usefull, but I couldn't handle them :(

Could someone write a simple app using wxThread, that would do sth simple like text output every 1 hour until the 'stop' is pressed, so that app during idleing takes little CPU ussage.
Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T »

Take a look at wxTimer http://docs.wxwidgets.org/stable/wx_wxt ... ml#wxtimer
I think it will do what you want.
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/
Post Reply