diff --git a/reference/ParallelProgress/ParallelProgress.upp b/reference/ParallelProgress/ParallelProgress.upp new file mode 100644 index 000000000..cfa437226 --- /dev/null +++ b/reference/ParallelProgress/ParallelProgress.upp @@ -0,0 +1,11 @@ +description "CoDo Parallel loop with progress indicator\377"; + +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/reference/ParallelProgress/main.cpp b/reference/ParallelProgress/main.cpp new file mode 100644 index 000000000..46e285119 --- /dev/null +++ b/reference/ParallelProgress/main.cpp @@ -0,0 +1,19 @@ +#include + +using namespace Upp; + +GUI_APP_MAIN +{ + Progress pi("Working on many items at once...", 100); + std::atomic ii(0); + CoDo([&] { + for(int i = ii++; i < 100; i = ii++) { + for(int q = 0; q < 1000; q++) { + if(pi.Canceled()) // ideally call canceled every 1-10ms + return; + Sleep(1); // work simulation + } + pi.Step(); + } + }); +}