diff --git a/src/xpdev/clx/ThreadCreate/MainUnit.h b/src/xpdev/clx/ThreadCreate/MainUnit.h index 7f33e93e48d4842bfc7313f9af4e33ed0a0218b2..9a26475dc27702c7ca2641120010212339073f94 100644 --- a/src/xpdev/clx/ThreadCreate/MainUnit.h +++ b/src/xpdev/clx/ThreadCreate/MainUnit.h @@ -8,6 +8,9 @@ #include <QControls.hpp> #include <QStdCtrls.hpp> #include <QForms.hpp> +#include <QComCtrls.hpp> +#include <QExtCtrls.hpp> +#include <QTypes.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { @@ -16,10 +19,14 @@ __published: // IDE-managed Components TButton *CreateButton; TButton *KillButton; TMemo *Log; + TStatusBar *StatusBar; + TTimer *Timer; void __fastcall CreateButtonClick(TObject *Sender); void __fastcall KillButtonClick(TObject *Sender); + void __fastcall TimerTick(TObject *Sender); private: // User declarations public: // User declarations + TList* List; TCriticalSection* CriticalSection; __fastcall TForm1(TComponent* Owner); }; diff --git a/src/xpdev/clx/ThreadCreate/MainUnit.xfm b/src/xpdev/clx/ThreadCreate/MainUnit.xfm index e18ba8fcbdba4c6ae2ce1aeb6ba3cc5ead4dffd8..190b16fc0491d26348a016c1d32457d91a2ee483 100644 --- a/src/xpdev/clx/ThreadCreate/MainUnit.xfm +++ b/src/xpdev/clx/ThreadCreate/MainUnit.xfm @@ -2,8 +2,8 @@ object Form1: TForm1 Left = 536 Top = 314 Width = 211 - Height = 283 - VertScrollBar.Range = 273 + Height = 303 + VertScrollBar.Range = 292 HorzScrollBar.Range = 203 ActiveControl = ListBox Caption = 'Form1' @@ -45,4 +45,17 @@ object Form1: TForm1 ScrollBars = ssAutoBoth TabOrder = 3 end + object StatusBar: TStatusBar + Left = 0 + Top = 284 + Width = 211 + Height = 19 + Panels = <> + SimplePanel = True + end + object Timer: TTimer + OnTimer = TimerTick + Left = 96 + Top = 144 + end end diff --git a/src/xpdev/clx/ThreadCreate/ThreadUnit.cpp b/src/xpdev/clx/ThreadCreate/ThreadUnit.cpp index 8bb343dede30d3c85c1d836bd2d31b2c185e10c0..b850c061694f5abbce083816c5121417c85014bb 100644 --- a/src/xpdev/clx/ThreadCreate/ThreadUnit.cpp +++ b/src/xpdev/clx/ThreadCreate/ThreadUnit.cpp @@ -25,14 +25,19 @@ __fastcall TMyThread::TMyThread(bool CreateSuspended) : TThread(CreateSuspended) { } +void __fastcall TMyThread::AddToLog() +{ + Log->Lines->Add(ThreadID); +} //--------------------------------------------------------------------------- void __fastcall TMyThread::Execute() { while(!Terminated) { - CriticalSection->Enter(); - Log->Lines->Add(ThreadID); + Synchronize(AddToLog); + CriticalSection->Enter(); + List->Add(new AnsiString(ThreadID)); CriticalSection->Leave(); - Sleep(1000); + Sleep(1); } } //--------------------------------------------------------------------------- diff --git a/src/xpdev/clx/ThreadCreate/ThreadUnit.h b/src/xpdev/clx/ThreadCreate/ThreadUnit.h index 144ae0c88f493e3106d82122934480fc7f40da3d..0bf617eae950bf296b81a6be90e8a2aa8b9b91d3 100644 --- a/src/xpdev/clx/ThreadCreate/ThreadUnit.h +++ b/src/xpdev/clx/ThreadCreate/ThreadUnit.h @@ -14,8 +14,10 @@ protected: void __fastcall Execute(); public: TMemo* Log; + TList* List; TCriticalSection* CriticalSection; __fastcall TMyThread(bool CreateSuspended); + void __fastcall AddToLog(void); }; //--------------------------------------------------------------------------- #endif