From 73a29f72fc76af96fbdfd54239c42494236d1aae Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 17 May 2009 13:26:50 +0000 Subject: [PATCH] upptst: Improved GuiMtTest git-svn-id: svn://ultimatepp.org/upp/trunk@1202 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- upptst/GuiMtTest/main.cpp | 136 +++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/upptst/GuiMtTest/main.cpp b/upptst/GuiMtTest/main.cpp index 8c850f4da..7b3eabf3a 100644 --- a/upptst/GuiMtTest/main.cpp +++ b/upptst/GuiMtTest/main.cpp @@ -1,68 +1,68 @@ -#include - -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 + +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(); +}