🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: VC++ CSemaphore equivalent?

#2319
From: Robert G. Hoover
Date: Mon, 12 Mar 2007 18:31
46 lines
2705 bytes
Hmm.... that makes sense about the checkboxes. On further review, I realize that
my code does exactly what you say. I have internal bool variables that are
altered by the GUI checkboxes. I must have run into something similar a few
years back. ;)

Display() uses...

HDC hDC = GetDC(hWindow);

hWindow is passed in as ShellForm->Handle which I assume is the handle to the
window? (ShellForm is my main window, built from TCustomForm by BDS)

So if both threads are accessing the same memory then they'll still be waiting
on each other, and I wouldn't have seen it until now with this new
dual-processor? And TThread won't help me one bit, eh? ;)

Thanks,

Rob



Jonathan Benedicto wrote:
> 
>> 'process()' does nothing unless check marks are set in additional GUI
>> window. No
>> functions are called from this routine as no checkmarks are checked.
>> ex. if (VideoForm->BlurImage->Checked) BlurVideoImage();
> 
> That does not sound like that function is thread-safe. I'd use a couple
> bools to store the state of the checkboxes, and then check the bools in
> the thread, instead of checking the actual checkboxes.
> 
> 
>> 'display()' calls SendDIBitsToDevice()
> 
> Where do you get the device handle to pass to SendDIBitsToDevice?
> 
> 
>> Really, these threads should run independent of each other (I hope).
> 
> Yes they do, however, they access data that is used by both threads, and
> if the access is not written in a thread-safe manner, it will not work
> properly.
> 
> Jon
Technical Details
Message-ID: <45f59c41$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45f57403@newsgroups.borland.com> <45f59433$1@newsgroups.borland.com> <45f5973e$1@newsgroups.borland.com> <45f598bf$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,411b13b57e2ea81a
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 12 Mar 2007 14:31:02 -0400
From: "Robert G. Hoover" <not.a.real.address@anywhere.sorry>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: VC++ CSemaphore equivalent?
References: <45f57403@newsgroups.borland.com> <45f59433$1@newsgroups.borland.com> <45f5973e$1@newsgroups.borland.com> <45f598bf$1@newsgroups.borland.com>
In-Reply-To: <45f598bf$1@newsgroups.borland.com>
X-Enigmail-Version: 0.94.1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Antivirus: avast! (VPS 000723-1, 03/12/2007), Outbound message
X-Antivirus-Status: Not-Tested
NNTP-Posting-Host: 68.48.157.44
Message-ID: <45f59c41$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1173724225 68.48.157.44 (12 Mar 2007 11:30:25 -0800)
Lines: 46
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail