Please Help - Adding Controls to a form from a child thread 
Author Message
 Please Help - Adding Controls to a form from a child thread

Hi,
I've been struggling with this for some time.

I have a form which has a thread that does some data processing. At a
certain point in the thread I want to add a new controll to a groupbox in
the form.

How do i send a call from my processing thread to the main ui thread to add
the control?

Thanks
Tariq



Wed, 06 Oct 2004 05:39:08 GMT  
 Please Help - Adding Controls to a form from a child thread
From the Microsoft article titled:
    "Multithreaded Windows Forms Control Sample"
----------------------------------------------------------
Windows Forms uses the single-threaded apartment (STA) model because Windows
Forms is based on native Win32 windows that are inherently apartment
threaded. The STA model implies that a window can be created on any thread,
but it cannot switch threads once created, and all function calls to it must
occur on its creation thread. Outside Windows Forms,classes in the .NET
Framework use the free threading model. For information about threading in
the .NET Framework, see Threading.

The STA model requires that any methods on a control that need to be called
from outside the control's creation thread must be marshaled to (executed
on) the control's creation thread. The base class Control provides several
methods (Invoke, BeginInvoke, EndInvoke) for this purpose. Invoke makes
synchronous method calls; BeginInvoke makes asynchronous method calls.
----------------------------------------------------------
There is a sample with that article as well.
Hope this helps.

Chris R.


Quote:
> Hi,
> I've been struggling with this for some time.

> I have a form which has a thread that does some data processing. At a
> certain point in the thread I want to add a new controll to a groupbox in
> the form.

> How do i send a call from my processing thread to the main ui thread to
add
> the control?

> Thanks
> Tariq



Wed, 06 Oct 2004 09:24:32 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Please Help with adding forms.

2. Please help with adding/changing form views

3. How develop MDI application with child forms like VB MDI and Child forms

4. Mouse Move for a child control - Help please.

5. Please Help with Form Controls

6. How to add scroll bars to a mdi program child form

7. container control that runs its children controls in an other thread

8. Dialog Controls in a Thread--Help Please

9. Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!

10. How develop MDI form with child forms

11. How to let parent form listening MDI child Form

12. adding WebBrowser Control to child window

 

 
Powered by phpBB® Forum Software