🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Unblock thread with PostMessage()?

#16153
From: Peter Stefanos
Date: Thu, 29 May 2003 05:10
45 lines
2513 bytes
Nick B. Cassos wrote:


(snip)

> 
> The main thread (responsible for the GUI) could actually handle it in
> - for example - the OnIdle handler:
> 
> void __fastcall TMainForm::MyIdle(TObject* Sender, bool &Done)
> {
>     if (EventAvailable)
>     {
>         EventAvailable = false;
> 
> 	while (PopEvent())
> 	{
> 	    HandleEvent();
> 	}
>     }
> }
> 
> Of course I am just guessing here, because I do not know the inner
> workings of your thread, how critical it is, etc. I am just proposing
> a way to avoid tighting a worker thread to the main one. If your
> worker thread needs immediate attention then you still could handle
> everything in the "OnEvent" handler * except * any action requiring
> user intervention. If such a case occurs, you could still use the
> above trick. 
> 

Nick,

Maybe the choice of title for this posting is a bit misleading... sorry.

I understand that the solution to this is the use of some "asynchronous" 
process such as OnIdle, or a timer event to get the main thread into the 
message loop before calling the users event handler (which may require 
user intervention).

But I am writing a TComPort class which will be used in half a dozen 
applications. How would I write this into the class? (I am a bit of 
novice when writing classes)

Peter.
Technical Details
Message-ID: <3ed59664$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3ed2f25e@newsgroups.borland.com> <0fu6dv066f6u49kga1ljaqt8pes48qve8q@4ax.com> <3ed402a7@newsgroups.borland.com> <d5i8dv86p6uqpva24enmom8eoe1h1n9q6l@4ax.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-28 22:12:03 PST
Date: Thu, 29 May 2003 15:10:38 +1000
From: Peter Stefanos <peterATpennywiseDOTcomDOTau>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
X-Accept-Language: en-au, en-us
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Unblock thread with PostMessage()?
References: <3ed2f25e@newsgroups.borland.com> <0fu6dv066f6u49kga1ljaqt8pes48qve8q@4ax.com> <3ed402a7@newsgroups.borland.com> <d5i8dv86p6uqpva24enmom8eoe1h1n9q6l@4ax.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 202.45.113.90
Message-ID: <3ed59664$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1054185060 202.45.113.90 (28 May 2003 22:11:00 -0700)
Lines: 46
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail