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 #53539 is a reply to message #53538] Thu, 09 April 2020 13:13 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
This works:

GUI_APP_MAIN
{
	Progress pg;
	pg.Title("A parallel processing job");
	pg.SetText("Working on many items at once...");
	pg.Set(0, 100);
	
	std::atomic<int> ii(0);
	CoDo([&] {
		for(int i = ii++; i < 100 ; i = ii++) {
			Sleep(1000); // Doing something...
			
			// OK, now it is done, update progress:
			
			if(IsMainThread())
				pg.SetPos(ii);
		}
	});
}


(CoDo is "new and shiny" variant of CoWork::*)

I will try to make this into the CtrlLib.

Mirek
 
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: Mon Aug 25 16:40:57 CEST 2025

Total time taken to generate the page: 0.06286 seconds