Update a VCL component from CreateAnonymousThread

delphi, delphi-xe, multithreading

Solution

You can use synchronize in this case, e.g.:

TThread.Synchronize(nil, procedure begin UpdateComponent(); end);

And if you want asynchronous method call execution within the main thread, you can use `TThread.Queue`, e.g.:

TThread.Queue(nil, procedure begin UpdateComponent(); end);

Problem

It seems which Synchronize cannot be used from a Thread created using CreateAnonymousThread, so the question is : `How i can update a VCL component from inside of a Thread created using CreateAnonymousThread? ` ``` TThread.CreateAnonymousThread(procedure begin //do something UpdateCompnent();//how I can update a VCL component from here? end ).Start; ```

Original source