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 #53514 is a reply to message #53511] Tue, 07 April 2020 16:39 Go to previous messageGo to previous message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi,

I finally found the solution:

	Progress pg;
	pg.Title("A parallel processing job");
	pg.SetText("Working on many items at once...");
	pg.Set(0, 100);

	Atomic done=0;
	Atomic stop=0;

	CoWork co;
	for(int t=0;t<co.GetPoolSize();t++){
		co & [&] {
			for(int i = AtomicInc(done); i<100;i = AtomicInc(done)){
				Sleep(1000); // Doing something...
				if(stop) break;
			}
		};
	}
	
	while(!co.IsFinished()){
		if(pg.Canceled()){
			AtomicInc(stop);
			break;
		}
		pg.SetPos(done);
		Sleep(100);
	}
	co.Finish();


So, in the end I did have to give up the CoWork::Loop (operator *) and do approximately the same externally to avoid internal co.Finish(); Now the GUI is accessed entirely in the main thread and there are no more issues.

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: Sun May 24 14:21:31 GMT+2 2026

Total time taken to generate the page: 0.00705 seconds