🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Unblock thread with PostMessage()?

#16211
From: Nick B. Cassos
Date: Tue, 27 May 2003 14:53
26 lines
1995 bytes
On Tue, 27 May 2003 15:06:17 +1000, Peter Stefanos
<peterATpennywiseDOTcomDOTau> wrote:

>...
>I have read a few postings about using PostMessage() (no pun intended) 
>but I do not know how to implement it without putting the message 
>handler method and message map in the users form class manually.
>Any ideas? Is this the best way to do this? Is there a simpler way?
>...

You can implement your own queue. A simple TStringList may be enough,
using the Objects property to hold event types, for example, and the
Strings property to hold information. For less simple structures you
could use a TList or better a TThreadList.

Protect your "queue" with a TCriticalSection (if it is not the
TThreadList) and offer the user some functions to handle it (e.g.
PopEvent())

No need to use PostMessage or Synchronize(), and your thread can keep
working. You may also offer a maximum number of Events that the queue
may hold, before your thread goes for sleep, etc.

-- 

Nick B. Cassos
Technical Details
Message-ID: <0fu6dv066f6u49kga1ljaqt8pes48qve8q@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3ed2f25e@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,679ed0dfb63f4be3
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-27 08:36:21 PST
From: Nick B. Cassos <nbc@no_spam.ath.forthnet.gr>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Unblock thread with PostMessage()?
Date: Tue, 27 May 2003 17:53:37 +0300
Message-ID: <0fu6dv066f6u49kga1ljaqt8pes48qve8q@4ax.com>
References: <3ed2f25e@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 213.16.148.157
X-Trace: newsgroups.borland.com 1054047217 213.16.148.157 (27 May 2003 07:53:37 -0700)
Lines: 26
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail