| jojo212 (34) | |||||
|
Hey guys, My program occasionally has to do a little bit of heavy lifting processing wise, and I'd like a function that says something to the effect of Now 40% complete... Now 83% complete... etc. I have the function written and it works, but it calls so fast that the screen just fills up with Now 1% Now 2% Now 3% etc. What I would like is the function to only be called once per second. HOWEVER what I DON'T want to do is use the sleep() or a wait() function because that will stop the programming from running altogether. I want something more along the lines of...
Do you see what I mean? Every answer I find about timing always has to do with pausing or sleeping, but that's not what I'm looking for. Look forward to hearing your thoughts. Much thanks! | |||||
|
Last edited on
|
|||||
| Moschops (5981) | |
|
Win32 provides timers for this sort of thing. http://twigstechtips.blogspot.co.uk/2011/02/c-setting-up-win32-timer.html | |
|
Last edited on
|
|
| Imadatobanisa (647) | |||
Sorry, but, you may try :
Also you may try the another method : Create a calculation thread and do the process bar code, instead of sleeping the main thread. That's better. Edit : If you want to use the function "settimer", specify and handle the message WM_TIMER | |||
|
Last edited on
|
|||
| jojo212 (34) | |
| Thanks for the ideas but I'm just going to scrap this feature. Doesn't seem like it's worth the trouble. Thanks anyway! | |
|
|
|
| freddie1 (847) | |
| Your original idea was a good one, and its not hard to do. You just need to use a seperate thread of excution for the processing. You can look at the CreateThread() Api function. If you don't try it you won't learn anything. I don't have time to post code now, but perhaps late tomorrow. | |
|
|
|
| jojo212 (34) | ||
Very true, sir! And it does sound like a very good thing to know :) This particular assignment is due in 2 hours, so I don't think I'm going to learn it before then, but you are definitely correct. | ||
|
|
||