To create a separate routine

  1. Write a main thread routine that handles accessing object properties and executing object methods for all objects in your application.
  2. Call the routine from your thread's Synchronize method. This is an example.

procedure TMyThread.PushTheButton begin

Button1.Click; end;

procedure TMyThread.Execute; begin

Synchronize(PushThebutton); end;

Synchronize waits for the main thread to enter the message loop and then executes the passed method.

Note: Because Synchronize uses a message loop, it does not work in console applications. For console applications, use other mechanisms, such as critical sections, to protect access to VCL objects.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment