[DUG] graphics stops updating

Allan, Samuel S.A.Allan at massey.ac.nz
Mon Jun 20 11:17:52 NZST 2005


Plain old integer variables are not threadsafe.

However, if you have only one thread which writes to the variable, and
all others only read it, then you should be more or less safe. Even then
it is a bit dodgy.

To be safe you should protect access to your integer with
TCriticalSection or one of the other concurrency constructs. And if you
are gonna do that, then it would be best to encapsulate this within a
class to ensure that the concurrency construct chosen is always used
when accessing the variable. While I don't know what the stats object
is, I guess this is more or less what it does.


-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]
On Behalf Of Ross Levis
Sent: Sunday, June 19 2005 5:47 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] graphics stops updating


Plain old integer variables are threadsafe.  So rather than adding the 
overhead of the stat object you suggested, I am simply assigning the 
Left & Right values to Private global integers and accessing them with a

timer.  It's been working perfectly for 10 minutes which is a record.

Cheers,
Ross.

----- Original Message ----- 
From: "Matt Comb" <matt at ferndigital.com>
To: "NZ Borland Developers Group - Delphi List" <delphi at ns3.123.co.nz>
Sent: Sunday, June 19, 2005 5:35 PM
Subject: Re: [DUG] graphics stops updating


Yer the problem is that whatever you are executing in the event of this
audio component is running in that audio components thread also, so you
can't directly access anything from the main thread without making it
threadsafe first.

If you use the stats object as suggested I think you will be fine.

Catch ya,

Matt 

_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi



More information about the Delphi mailing list