You didn't understand my question. I'm already executing some work in a
background thread but I would like to execute a method in main-thread.
Myexample: worker thread has some data which has to be displayed. I must not
update controls from this thread, so I must somehow pass this data to
main-thread. And I wan't to do this async so worker thread continues working
while controls are updated. In Win32 the perfect solution to this is to send
message. Get my point now?
I think that they did understand. Whenever you create a control/form/
someUIpiece, the thread that is created on becomes the UI (aka, main)
thread. When you want to add children to a control, they have to be
created in the same thread as their parent. Whenever you want to call
some property or method on a control, you have to make that call from
the thread where the control was created. To make this easy, the base
class for all controls and forms has Invoke and BeginInvoke methods.
You can call those functions from any thread (and same with the
Invalidate function). You pass the invokers a (delegate) function to
be called from the control's thread. BeginInvoke is asynchronous.
Invoke is synchronous (aka, blocking).
BTW, sending messages is certainly not the best solution; it's a pain
in the ars. I'm glad that .NET and SWT support these other invoke
methodologies.