diff --git a/upptst/ProgressMT/ProgressMT.upp b/upptst/ProgressMT/ProgressMT.upp new file mode 100644 index 000000000..5872304d3 --- /dev/null +++ b/upptst/ProgressMT/ProgressMT.upp @@ -0,0 +1,9 @@ +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/upptst/ProgressMT/main.cpp b/upptst/ProgressMT/main.cpp new file mode 100644 index 000000000..ccb7f1684 --- /dev/null +++ b/upptst/ProgressMT/main.cpp @@ -0,0 +1,38 @@ +#include + +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 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(); +}