upptst: Improved GuiMtTest

git-svn-id: svn://ultimatepp.org/upp/trunk@1202 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-05-17 13:26:50 +00:00
parent 83a110d989
commit 73a29f72fc

View file

@ -1,68 +1,68 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct App : TopWindow {
Thread work;
void Work();
ArrayCtrl list;
typedef App CLASSNAME;
App();
~App();
};
void Ask(bool *result)
{
*result = PromptYesNo("Do you want to quit?");
}
void App::Work()
{
int q = 0;
while(!Thread::IsShutdownThreads()) {
if(++q > 20) {
#if 0
bool result;
Call(callback1(Ask, &result));
if(result) {
Ctrl::Lock __(*this);
Break();
}
q = 0;
#else
if(PromptYesNo("Do you want to quit?")) {
Ctrl::Lock __(*this);
Break();
}
#endif
}
for(int i = 0; i < 101; i++) {
Ctrl::Lock __(list);
list.Set(i, 0, (int)Random());
}
Sleep(10);
}
}
App::App()
{
list.AddColumn("Test");
Add(list.SizePos());
work.Run(THISBACK(Work));
}
App::~App()
{
Thread::ShutdownThreads();
work.Wait();
}
GUI_APP_MAIN
{
App app;
app.Run();
}
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct App : TopWindow {
Thread work;
void Work();
ArrayCtrl list;
typedef App CLASSNAME;
App();
~App();
};
void Ask(bool *result)
{
*result = PromptYesNo("Do you want to quit?");
}
void App::Work()
{
int q = 0;
while(!Thread::IsShutdownThreads()) {
if(++q > 200) {
#if 0
bool result;
Call(callback1(Ask, &result));
if(result) {
Ctrl::Lock __(*this);
Break();
}
#else
if(PromptYesNo("Do you want to quit?")) {
Ctrl::Lock __(*this);
Break();
}
#endif
q = 0;
}
for(int i = 0; i < 101; i++) {
Ctrl::Lock __(list);
list.Set(i, 0, (int)Random());
}
Sleep(10);
}
}
App::App()
{
list.AddColumn("Test");
Add(list.SizePos());
work.Run(THISBACK(Work));
}
App::~App()
{
Thread::ShutdownThreads();
work.Wait();
}
GUI_APP_MAIN
{
App app;
app.Run();
}