TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Timo Sirainen
from: Peter Fitzsimmons
date: 1995-12-28 00:07:52
subject: Timeslices

TS> Can I give timeslices to OS/2 in OS/2 prog? Or how 
 TS> should I do this kind of program:

 TS> repeat
 TS>   if keypressed then
 TS>     begin
 TS>       c:=readkey;
 TS>       {...}
 TS>     end else
 TS>     begin
 TS>       give_timeslice; { Any way to do this in OS/2 prog? }
 TS>     end;
 TS> until quit;

This is a polling loop;  you never want one of these under OS/2. The above
code can be compleletely replaced with

       c:=readkey;

If you have work you want to do when a key is not pressed,  use another thread.


The short answer to your question is DosSleep();  but I'd hate for you just
to stick a DosSleep(1) in your original code;   a little redesign will
result in a program that has no polling loops.


--- Maximus/2 3.00
* Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 808 809 934 955 712/407 515
SEEN-BY: 712/517 628 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/99 3615/50 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.