ultimatepp/uppdev/guimtbug/main.cpp
cxl 6a809a7a5d Syncing uppdev
git-svn-id: svn://ultimatepp.org/upp/trunk@1825 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2009-12-21 10:33:12 +00:00

90 lines
1.3 KiB
C++

#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class TestThread : public TopWindow
{
protected:
bool stop;
void buttonCb(void);
Thread thr;
virtual void thrCb(void);
void Stop();
ProgressIndicator progress;
Button button;
StatusBar status;
public:
typedef TestThread CLASSNAME;
TestThread();
};
void TestThread::thrCb(void)
{
{
GuiLock __;
status.Set("Running, " + FormatInt(thr.GetCount()) + " threads");
}
for(;;)
{
{
GuiLock __;
if(progress < 100)
progress++;
else
progress = 0;
if(stop)
break;
}
Sleep(1000);
}
{
GuiLock __;
status.Set("Idle....");
}
PostCallback(THISBACK(Stop));
}
void TestThread::Stop()
{
button.SetLabel("START");
}
void TestThread::buttonCb(void)
{
if(stop)
{
stop = false;
button.SetLabel("STOP");
thr.Run(THISBACK(thrCb));
}
else
stop = true;
}
TestThread::TestThread()
{
SetRect(0, 0, 300, 150);
Add(button);
button.TopPos(90, 30).HCenterPos(100);
button.SetLabel("START");
Add(progress);
progress.TopPos(30, 40).HCenterPos(250);
progress.Set(0, 100);
AddFrame(status);
status.Set(" ");
stop = true;
button <<= THISBACK(buttonCb);
}
GUI_APP_MAIN
{
TestThread().Run();
}