void __fastcall TScreenThread::Execute(void)
{
//Keep running until the thread is terminated
while (!Terminated)
{
//Drop into the context of the UI thread to write the message to the screen
Synchronize(UpdateScreen);
}
}
//----------------------------------------------------------------------------
void __fastcall TScreenThread::UpdateScreen(void)
{
//If there are too many messages of the screen, clear it
if (Form1->mMessages->Lines->Count > 200)
Form1->mMessages->Lines->Clear();
//Write the message to the screen
Form1->mMessages->Lines->Add(Message);
}