Article View: borland.public.cppbuilder.nativeapi
Article #347Re: Moving hooke callback to thread - suggestions? (was:Hooks, once again)
From: Bob Gonder
Date: Thu, 08 May 2008 15:05
Date: Thu, 08 May 2008 15:05
30 lines
2328 bytes
2328 bytes
Anders Johansen wrote:
>The problem is however that if you include this code in a program that blocks the message processing loop
> (say, by doing while (true) {};)
Don't do that!
Never put that kind of code in the main thread.
> the system temporarily becomes unresponsive, as the callbacks are blocked
> from executing for some reason.
Because the main thread is executing blocking code instead of running the message pump.
>This is why I expect that moving the event processing etc. to another thread is a Good Idea.
No, moving blocking code to another thread is a Good Idea.
>Of course, this introduces a risk that the event handlers could be run outside the main thread, which would create problems with VCL code I expect.
Yes. See Syncronize()
>Therefore my idea is:
>* Place Hook code in separate thread
Hook code belongs in Main Thread.
>* Convert events to window messages sent asynchronously to the main thread (or some other way to avoid threading issues in VCL).
Run the virtual obs->keyDown() functions from threads.
The virtual obs->keyDown() functions should use Syncronize() to update VCL controls.
Technical Details
Message-ID:
<3056249n55n21hr9aeq4di1130seokqia4@4ax.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!eweka.nl!lightspeed.eweka.nl!195.114.231.69.MISMATCH!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<47c935cb$1@newsgroups.borland.com> <48217905$1@newsgroups.borland.com> <24c3249pbvhtdcpjihmskrvr9pisljt7g6@4ax.com> <4822c89f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,4ebd883022a89a5d X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Moving hooke callback to thread - suggestions? (was:Hooks, once again) Date: Thu, 08 May 2008 08:05:13 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <3056249n55n21hr9aeq4di1130seokqia4@4ax.com> References: <47c935cb$1@newsgroups.borland.com> <48217905$1@newsgroups.borland.com> <24c3249pbvhtdcpjihmskrvr9pisljt7g6@4ax.com> <4822c89f$1@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: 67.77.145.6 X-Trace: newsgroups.borland.com 1210259112 67.77.145.6 (8 May 2008 08:05:12 -0700) Lines: 32 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!eweka.nl!lightspeed.eweka.nl!195.114.231.69.MISMATCH!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail