[DUG] graphics stops updating
Matt Comb
matt at ferndigital.com
Sun Jun 19 17:35:02 NZST 2005
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.
----- Original Message -----
From: "Ross Levis" <ross at stationplaylist.com>
To: "NZ Borland Developers Group - Delphi List" <delphi at ns3.123.co.nz>
Sent: Sunday, June 19, 2005 5:28 PM
Subject: Re: [DUG] graphics stops updating
> I've notified the author of the audio suite of the problem. I'm not
> accessing the thread directly, in fact, I only know it uses a thread
> because the web page says so. My little app is only a few lines long
> with some components on a form.
>
> Perhaps I should not be doing UI stuff in this event. It is an event
> triggered by the audio component when data is available. It is an IDE
> published event so you would think it should handle UI stuff, but the
> audio component probably doesn't want anything slowing down the internal
> thread, otherwise, audio data could be lost.
>
> So I may need to copy the data to a global variable and access it on a
> timer as you suggested.
>
> 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:03 PM
> Subject: Re: [DUG] graphics stops updating
>
>
> I would consider creating something like a stats object as an
> intermediary
> between your reading thread and the updating on the main thread.
> Something
> along the lines of the following.
>
> Update the values that you need in the update events from the read
> thread,
> then on the mainform have a timer which also reads from this object.
>
> Matt.
>
>
> type
> TStatOb = class(Tobject)
> private
> fVal1:integer;
> fSC_Val1:tCriticalSection;
> function ReadVal1:integer;
> procedure SetVal1(value:integer);
> public
> constructor create;
> destructor destroy; override;
> property Val1:integer read ReadVal1 write SetVal1;
> end;
>
> implementation
>
> { TStatOb }
>
> constructor TStatOb.create;
> begin
> fSC_Val1:=tcriticalsection.create;
> end;
>
> destructor TStatOb.destroy;
> begin
> fSC_Val1.free;
> inherited;
> end;
>
> function TStatOb.ReadVal1: integer;
> begin
> fSC_Val1.Enter;
> result:=fval1;
> fSC_Val1.Leave;
> end;
>
> procedure TStatOb.SetVal1(value: integer);
> begin
> fSC_Val1.Enter;
> fval1:=value;
> fSC_Val1.Leave;
> end;
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
More information about the Delphi
mailing list