I'm new to threads. I'm using a 3rd party library that uses threads which at times call a procedure I've provided.
How do I update update a TLabel.Caption from my procedure when its called by the thread?
If I've called InitializeCriticalSection elsewhere, is it as simple as
EnterCriticalSection(CritSect);
GlobalVariable := 'New TLabel.Caption';
LeaveCriticalSection(CritSect);
And then in my main thread:
EnterCriticalSection(CritSect);
Label1.Caption:= GlobalVariable;
LeaveCriticalSection(CritSect);
But, how do I get the main thread code to be called? The thread can use SendMessage? Or is there some better/easier way (.OnIdle could check a flag set by the thread?)
Thanks.