On Sun, 9 Oct 2011 08:14:41 +0100
Frank Church <[email protected]> wrote:

> On 9 October 2011 07:30, Mattias Gaertner <[email protected]> wrote:
> 
> > On Sun, 9 Oct 2011 00:22:10 +0100
> > Frank Church <[email protected]> wrote:
> >
> > > Are multiple critical sections allowed in form or data module?
> > >
> > > e.g. I have different datasets each with its own connection and queries
> > that
> > > threads need to lookup data from.
> > >
> > > Is it acceptable to have additional TCriticalSections on the form?
> >
> > Yes.
> > I hope you are aware that all code accessing the LCL must run in the
> > main thread.
> >
> > Mattias
> >
> >
> Can you explain this?
> Do you mean that TCriticalSection is part of the LCL and shouldn't be run
> from within a thread, or that code within the thread or the critical section
> must not run code accessing the LCL?

All LCL code that deals with Application, TControl or widget handles is
not thread safe and should only be accessed by the main thread.
When another thread needs to access these LCL parts it should do it via
the main thread, for example via Synchronize.

 
> How is it determined whether a piece of code runs within the LCL or not?

if GetCurrentThreadID=MainThreadID then

Mattias

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to