Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » is there a function to stop the program N milliseconds?
is there a function to stop the program N milliseconds? [message #11842] Thu, 27 September 2007 15:25 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I tried Wait(1000) but the compiler complains:

C:\MyApps\GuiStableMarriage\StableMarriage.cpp:68: error: 'Wait' was not declared in this scope

I need to pause the program to let the user to observe some calculation.
Thanks,
Luigi
Re: is there a function to stop the program N milliseconds? [message #11846 is a reply to message #11842] Thu, 27 September 2007 17:50 Go to previous messageGo to next message
sergei is currently offline  sergei
Messages: 94
Registered: September 2007
Member
Sleep(1000)
Re: is there a function to stop the program N milliseconds? [message #11854 is a reply to message #11842] Fri, 28 September 2007 11:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Thu, 27 September 2007 09:25

Hello,

I tried Wait(1000) but the compiler complains:

C:\MyApps\GuiStableMarriage\StableMarriage.cpp:68: error: 'Wait' was not declared in this scope

I need to pause the program to let the user to observe some calculation.
Thanks,
Luigi



Sleep(1000) is possible, but it will completely freeze your code for 1 second, including repainting.

I think you should rather use timer for this...

Mirek
Re: is there a function to stop the program N milliseconds? [message #11977 is a reply to message #11854] Fri, 05 October 2007 22:39 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Fri, 28 September 2007 11:41



Sleep(1000) is possible, but it will completely freeze your code for 1 second, including repainting.

I think you should rather use timer for this...

Mirek


Hello,

in my code I used Sleep(500)
...
  for (int i=0; i<arrlog.GetCount(); i++)
      { arrlog.SetCursor(i); // bool sel = true).SetCursor(i);
        Sleep(500);
      }
...

I wanted to move the cursor in turn on the rows of the array to trigger some action somewhere else. Instead I couldn't see anything except the final result when the cursor was in the last row. So I lost all the intermediate steps.
Then I decided to try 'timer' but what is it? Navigate suggest me only

void Ctrl::TimerProc(dword time)

how to use it? I just want to pause the program a fraction of second during the movement of the cursor of the arrayctrl.
Thanks.
Luigi
Re: is there a function to stop the program N milliseconds? [message #11982 is a reply to message #11977] Sat, 06 October 2007 17:50 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, you perhaps can eventually use Sleep here, but call Sync (e.g. for your TopWindow) so that any visual changes are displayed immediately.

Anyway, to do it with timer, the recommended way is to add TimeCallback member variable and use its methods.

Mirek
Previous Topic: Crash on LoadFromFile
Next Topic: How to read file into Memory
Goto Forum:
  


Current Time: Sun May 05 07:25:33 CEST 2024

Total time taken to generate the page: 0.02775 seconds