File:  [Synchronet] / sbbs / src / xpdev / clx / threadcreate / threadunit.cpp
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:41:24 2018 UTC (8 years, 3 months ago) by root
Branches: digitaldynamics, MAIN
CVS tags: v_315b, v_314a, HEAD
3.14a


//---------------------------------------------------------------------------

#include <clx.h>
#pragma hdrstop

#include "ThreadUnit.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------

//   Important: Methods and properties of objects in CLX can only be
//   used in a method called using Synchronize, for example:
//
//      Synchronize(UpdateCaption);
//
//   where UpdateCaption could look like:
//
//      void __fastcall TMyThread::UpdateCaption()
//      {
//        Form1->Caption = "Updated in a thread";
//      }
//---------------------------------------------------------------------------

__fastcall TMyThread::TMyThread(bool CreateSuspended)
	: TThread(CreateSuspended)
{
}
void __fastcall TMyThread::AddToLog()
{
    	Log->Lines->Add(ThreadID);
}
//---------------------------------------------------------------------------
void __fastcall TMyThread::Execute()
{
	while(!Terminated) {
    	Synchronize(AddToLog);
        /* TThreadList is a simplier way to use a thread-safe TList */
		CriticalSection->Enter();
		List->Add(new AnsiString(ThreadID));
        CriticalSection->Leave();
 	    Sleep(1000);
    }
}
//---------------------------------------------------------------------------

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.