🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: TThread with messages

#16267
From: Rob
Date: Sun, 25 May 2003 06:25
38 lines
2576 bytes
"Lapo" <lapoguidi@inwind.it> wrote in message
news:3ed00a13@newsgroups.borland.com...
> Hi all,
> I'm coding a program to show a serie of jpeg from a network camera in a
> TImage.
> Following suggestions of this newsgroup, I used a TThread to get a jpeg
and
> to show one after another.
> I used the Synchronize method to update the TImage content.
> Now the question:
> I see that every time the TImage is updated using Synchronize, as a said
> before, the Thread seems freezed until the updating is done.

Sure.  That is what Synchronize() is designed to do.  It blocks the calling
thread until the function is called by the main GUI thread.

> Well, I read something about PostMessage/SendMessage to communicate from
> Thread to Main Application, so the thread can ask the main application to
> update the TImage and it doesn't wait for the updating is over.

PostMessage would be the solution here.   Keep in mind that some messages
(eg WM_COPYDATA) can't be sent by PostMessage.  You will also need to
have a defined way of getting data from one thread to the other.

SendMessage blocks the caller until the window receiving the message has
acted on the message.  IOW, you will see exactly the same effect as you
would with using Synchronize().

> I tried to manage it, but I'm lost.
> Maybe somebody have a sample or an url or a code snip... I really hope it.
>

One of the challenges of multithreaded programming comes when you
need to process data on one thread and show (or even access) the
results through another.   Keep in mind that the process of getting data
to the other thread is always something that requires some form of
synchronisation.
Technical Details
Message-ID: <3ed0627c@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3ed00a13@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,9f6b69458a9a485d
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-05-24 23:30:36 PST
From: "Rob" <nospam@nonexistant.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3ed00a13@newsgroups.borland.com>
Subject: Re: TThread with messages
Date: Sun, 25 May 2003 15:55:17 +0930
Lines: 41
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 211.26.120.22
Message-ID: <3ed0627c@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1053844092 211.26.120.22 (24 May 2003 23:28:12 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail