Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » How to use CoWork and Progress together?
Re: How to use CoWork and Progress together? [message #53554 is a reply to message #53540] Sat, 11 April 2020 11:14 Go to previous messageGo to previous message
Tom1
Messages: 1216
Registered: March 2007
Senior Contributor
Hi Mirek,

This is a nice and stylish improvement!

However, there is still something to fix as using this through a menu leaves the app frozen at or near the completion of parallel processing. Here's a testcase based on the reference example:

#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);
		std::atomic<int> 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();
			}
		});
	}
	
	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();
}


Thanks and best regards,

Tom
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [NOT REPRODUCIBLE] HttpRequest gzip format error
Next Topic: ASyncWork/CoWork Cancel() method leads to deadlock (when used with GuiLock)
Goto Forum:
  


Current Time: Thu May 16 11:46:19 CEST 2024

Total time taken to generate the page: 0.02332 seconds