VCL multi-theading issues

Giganews Newsgroups
Subject: VCL multi-theading issues
Posted by:  David M (davi…@sonardata.com)
Date: Wed, 14 Jun 2006

(Originally posted via Google, reposted to Borland servers.)
Hi,

I know the majority of the VCL is not threadsafe, and I've read that
you should only use VCL components from the main thread.  I'd like to
know if it's possible to use the VCL from several threads and what the
issues are in doing so.
The reason I'm asking (in case this helps answer it) is that an
application I work on does a lot of processing in its main thread.
Moving this to another thread is not possible.  I'd like to provide
some entirely separate functionality through a tray icon that would
open a form etc, and because it should be accessible all the time I was
thinking I could create a separate thread object, and have it create
the tray icon and the associated forms etc that the user accesses
through it.  Any communication between the main thread and the tray
applet one would be done by passing messages (there's not much to
pass.)  Thus any long processing in the main thread wouldn't stop the
user interacting with the tray thread.

What I'm wondering is if doing something like this is going to cause
problems.  I would simply build it and see but threading issues tend to
only show up occasionally - I don't want to do it, have it work, think
it's okay, and then find out months later it was stupid thing to do.

Any suggestions or info about what is and isn't safe with the VCL like
this will be greatly appreciated :)

Cheers,

David

Replies