U++ framework
Do not panic. Ask here before giving up.

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: 14291
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: Sun May 24 17:14:42 GMT+2 2026

Total time taken to generate the page: 0.00470 seconds