🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: ProcessMessages / HandleMessage ???

#1587
From: Remy Lebeau (TeamB)
Date: Thu, 19 Jul 2007 17:05
33 lines
2215 bytes
"Thorsten Kettner" <QUESTIONBYthorsten.kettner@otto.de> wrote in message
news:469f87af$1@newsgroups.borland.com...

> I must tell it to give time to the other apps, too, right?

You must perform a yielding operation periodically that allows your app to
give up the rest of its CPU timeslice so that other apps can have a chance
to use the CPU.  Something as simple as a call to Sleep() with a timeout
between 0-10 ms will usually do the trick.

> I was told to avoid a so-called tight loop by calling
> ProcessMessages every now and then. Is that the right
> way? Does it give time to other apps or just to my own
> message processing?

That depends on the amount of message traffic you have.  If you have a lot
of pending messages, then it may or may not yield right away.

> I would like my app to concentrate on its loop and do only
> this actually, I don't care much about my apps messages
> in that situation.

> I want other apps to continue to run fast and not be infuenced
> much by my app being busy with its loop. So what is the right
> way to do this?

If you don't care about the messages, then use Sleep() in the loop.
Otherwise, you should move the code into a worker thread and let the main
thread handle its messages normally.


Gambit
Technical Details
Message-ID: <469f99e7$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <469f87af$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,130d1808941e9622
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <469f87af$1@newsgroups.borland.com>
Subject: Re: ProcessMessages / HandleMessage ???
Date: Thu, 19 Jul 2007 10:05:27 -0700
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.82.252.126
Message-ID: <469f99e7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1184864743 75.82.252.126 (19 Jul 2007 10:05:43 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail