BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help...Problem updating Form from thread

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE)
View previous topic :: View next topic  
Author Message
Jay Helmericks
Guest





PostPosted: Mon Sep 22, 2003 6:35 pm    Post subject: Help...Problem updating Form from thread Reply with quote



I'm trying to update a form from a thread and it is locking up the GUI. I
have a main form that spawns a thread that accepts TCP/IP connections. For
each incoming connection an new form is created to display the connection
info. The thread calls a syncronize method to update the form. It works if I
display the info on the main form, but when I write to the second form the
GUI freezes. The program still exicutes fine, but I can't click any buttons,
etc... The new form was created with new.

Jay


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Sep 22, 2003 6:47 pm    Post subject: Re: Help...Problem updating Form from thread Reply with quote




"Jay Helmericks" <jayh (AT) gi (DOT) alaska.edu> wrote

Quote:
I'm trying to update a form from a thread and it is locking up the GUI.

Are you using the thread's Synchronize() method? If not, you need to. The
VCL is not thread-safe, you must use Synchronize() when accessing the main
VCL thread, particularly GUI elements.

Quote:
I have a main form that spawns a thread that accepts TCP/IP connections.
For each incoming connection an new form is created to display the
connection
info. The thread calls a syncronize method to update the form. It works if
I
display the info on the main form, but when I write to the second form the
GUI freezes. The program still exicutes fine, but I can't click any
buttons,
etc... The new form was created with new.

It sounds like you are creating the new forms from within the context of the
worker thread, not the main VCL thread. If so, then you should not be doing
that. VCL forms should always be used in the context of the main VCL
thread. Without seeing your actual code, I would surmise that the reason
your secondary forms are not responsive is because your worker thread is not
running its own message queue. Windows process messages in the same thread
that created them. If you are indeed creating your secondary forms within
the context of the worker thread, then the thread needs its own message
queue. However, even that is not a guarantee that it will work properly,
again because the VCL is not thread-safe. Your best bet is to just use
Synchronize() to force the form creation to occur in the main VCL thread
instead, and always use Synchronize() when updating any GUI elements,
whether they are in the MainForm or the secondary forms.


Gambit



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.