returning user control during expensive loop

A

Anthony Knittel

i've got an expensive loop that keeps running for a long time, whats the
best way to put breaks in the program to return a bit of control to the
user instead of locking up the system? its just a single thread command
line program.

i'm using mingw so there is no sleep or usleep command, and i don't
think _sleep is doing what i want it to. ideally i'd like to just stick
in a little break somewhere in the loop to free things up.

when my program is running the output (stdout) gets filled up and
refreshes every few seconds, and the program doesn't respond to ctrl-c
or anything so i end up terminating it with task manager (its being
executed under cygwin but build independent of cygwin1.dll).


Anthony
 
V

velthuijsen

Shorten the loop. Store the data required to go on from the point where
you exited prematurely. Keep calling the function that contains the
loop until it is finished.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top