🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1333

Re: Console applicaton and sleep()

#1333
From: Ed Mulroy [TeamB]
Date: Tue, 18 Sep 2007 18:50
32 lines
2202 bytes
Put this function prototype at the top of your file immediately after the 
includes.

__declspec(dllimport)
extern "C"
void __stdcall Sleep(unsigned long millisec);

.  Ed

> Andre Steenveld wrote in message
> news:46f01013@newsgroups.borland.com...
>
> I've a problem with a console application and the Sleep() api call.
>
> What I need/want, in some states of the program, is to release the 
> timeslice in a console application while it is waiting on (non blocking) 
> user input. For that I need access to usleep(msec) or Sleep(msec). A call 
> to sleep(sec) is not realy an option. Users will notice a delay of one 
> second most certenly.
>
> The alternative is to do busy-waiting and keep the processor load at 100%. 
> Not a nice option.
> Another alternatice is to switch between blocking and non-blocking input 
> which doesn't sound atractive to me. (more code prone to buggy behaviour)
>
> Since the application is a console application I can't include 
> <windows.h>. If I do, a load of compile errors is the result.
> But to use sleep(), usleep() or Sleep() I must include <windows.h> 
> according to the documentation.
>
> Does someone know how to call a windows API call from a console 
> application? Does someone have a suggestion to tackle this problem?
Technical Details
Message-ID: <46f01e08$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <46f01013@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,12ae2dc26e53d1eb
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <46f01013@newsgroups.borland.com>
Subject: Re: Console applicaton and sleep()
Date: Tue, 18 Sep 2007 14:50:48 -0400
Lines: 34
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
NNTP-Posting-Host: 69.142.254.168
Message-ID: <46f01e08$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1190141448 69.142.254.168 (18 Sep 2007 11:50:48 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail