mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.upptst
git-svn-id: svn://ultimatepp.org/upp/trunk@14295 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
4f590458df
commit
45bc92d39c
2 changed files with 47 additions and 0 deletions
9
upptst/ProgressMT/ProgressMT.upp
Normal file
9
upptst/ProgressMT/ProgressMT.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
38
upptst/ProgressMT/main.cpp
Normal file
38
upptst/ProgressMT/main.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
class Test: public TopWindow{
|
||||
public:
|
||||
typedef Test CLASSNAME;
|
||||
MenuBar menu;
|
||||
|
||||
void Worker(){
|
||||
Progress pi("Working on many items at once...", 100*1000);
|
||||
std::atomic<int> ii(0);
|
||||
CoDo([&] {
|
||||
for(int i = ii++; i < 100; i = ii++) {
|
||||
for(int q = 0; q < 1000; q++) {
|
||||
if(pi.StepCanceled()) // ideally call Canceled every 1-10ms
|
||||
return;
|
||||
Sleep(1); // work simulation
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MainMenu(Bar &bar){
|
||||
bar.Add("Process...", THISFN(Worker));
|
||||
}
|
||||
|
||||
Test(){
|
||||
AddFrame(menu);
|
||||
menu.Set([=](Bar& bar) { MainMenu(bar); });
|
||||
}
|
||||
};
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
Test test;
|
||||
test.Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue