Article View: borland.public.cppbuilder.nativeapi
Article #13519Re: Thread synchronisation - Question
From: Remy Lebeau (TeamB)
Date: Tue, 07 Oct 2003 17:26
Date: Tue, 07 Oct 2003 17:26
24 lines
2362 bytes
2362 bytes
"Matt Heling" <heli@_REMOVE_THIS_heling.de> wrote in message news:3f82de8b@newsgroups.borland.com... > I'm trying to write a component, which in one thread fetches data > from some hardware (measurement data), whenever data should > be ready to be fetched, stores the data immediately into memory > buffer (a kind of a Fifo) and "tells" the other thread, it would now > be allowed to read the data, when it would be ready to do so. That's easy to do. Simply store the data into a TThreadList so that the data collecting is thread-safe, and then post a message to the main component whenever data is available. TThreadList makes sure that only 1 thread can access the data at any given time. Or, if you're using BCB6 only, then there is a new TQueue class that is already a FIFO container, just protect access to it using your own CriticalSection. If the component derives from TWinControl, then you can post the message to the component's Handle and intercept the message in the WndProc() method. Otherwise, call AllocateHWnd() in the contructor to allocate a hidden window that you can post to, and be sure to call DeallocateHWnd() in the destructor when the window is no longer needed. Gambit
Technical Details
Message-ID:
<3f82f6cd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeeds.sol.net!skynet.be!skynet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f704989@newsgroups.borland.com> <3f750c0d$2@newsgroups.borland.com> <3f818e8c@newsgroups.borland.com> <3f8198e0$1@newsgroups.borland.com> <3f82de8b@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,20b65b563d927a2d X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-10-07 10:41:34 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f704989@newsgroups.borland.com> <3f750c0d$2@newsgroups.borland.com> <3f818e8c@newsgroups.borland.com> <3f8198e0$1@newsgroups.borland.com> <3f82de8b@newsgroups.borland.com> Subject: Re: Thread synchronisation - Question Date: Tue, 7 Oct 2003 10:26:11 -0700 Lines: 26 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.137.75 Message-ID: <3f82f6cd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1065547469 67.22.137.75 (7 Oct 2003 10:24:29 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeeds.sol.net!skynet.be!skynet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail