home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!gatech!concert!sas!mozart.unx.sas.com!jamie
- From: jamie@cdevil.unx.sas.com (James Cooper)
- Subject: Re: Simple C question
- Originator: jamie@cdevil.unx.sas.com
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Message-ID: <C0DyoI.5z6@unx.sas.com>
- Date: Tue, 5 Jan 1993 14:53:06 GMT
- References: <C02JCH.pC@ccu.umanitoba.ca> <marc.01d7@aargh.adsp.sub.org> <1993Jan4.203607.5246@bilver.uucp>
- Nntp-Posting-Host: cdevil.unx.sas.com
- Organization: SAS Institute Inc.
- Lines: 36
-
-
- In article <1993Jan4.203607.5246@bilver.uucp>, alex@bilver.uucp (Alex Matulich) writes:
- >marc@aargh.adsp.sub.org (Marc Heuler) writes:
- >>umbadiu0@ccu.umanitoba.ca (Ted Babiuk) writes:
- >>>is there something simular to a sleep() command which puts a task to sleep
- >>>for 'x' ticks? (and uses little/no cpu time?)
- >>
- >>There is, it's Delay() of dos.library.
- >
- >I have a similar but more complex question:
- >
- >Is there something similar to Delay() that will put the program to sleep
- >for a specified period of time but ALSO be interrupted by a keystroke?
- >I'm using the timer device to do this in an application that must wait for
- >clock events (the program is a video subtitler for foreign films), and it
- >would be nice for the program to be able to hear keystrokes *before* the
- >sleep time has elapsed.
- >
- >I can do it with a busy loop, constantly checking the system time and the
- ^^^^^^^^^ ARRGGGHHHH!
- >keyboard, but I'd like to avoid this.
-
- How about just WaitForChar() in dos.library? It waits for a keypress for a
- specified time, returning immediately if a key *is* actually pressed.
-
- Otherwise, simply fire off a message to timer.device, and another to
- console.device, the Wait() on both signals. Be sure to AbortIO() the one
- that didn't come back, or it could show up later, though.
-
- --
- ---------------
- Jim Cooper
- (jamie@unx.sas.com) bix: jcooper
-
- Any opinions expressed herein are mine (Mine, all mine! Ha, ha, ha!),
- and not necessarily those of my employer.
-