Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Synchronise

Status
Not open for further replies.

nicasa

Programmer
Feb 3, 2003
54
ES
Hi All

What is the correct way to call synchronise() in a thread ? I want to be able to call a function using a pointer to main form like this:

synchronise(pMyForm->MyFunction());

It does not work !! Does MyFunction() need to be a vcl function ??

HELP ....

SteveM
 
I assume here a TThread.
Mark Cashman ( ) I think describes it very well.

"Synchronize is a special function provided by TThread. It acts like a critical section for accessing forms controlled by the main thread (the thread which is represented by your Project Source.cpp file). You pass it a pointer to a function in your thread class and Synchronize executes it as if it were a function in the main thread. Only one thread at a time can execute in the main thread context, so Synchronize lets you serialize access to main thread resources like controls and tables - where parallel (and potentially interrupted) access by multiple threads could leave important data structures in an inconsistent (and thus crash-prone) state."

Hope this helps.


------------------------------
Wisdom doesn't always come with age. Sometimes age comes alone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top