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 » Community » U++ community news and announcements » CoWork exceptions and IsCanceled
CoWork exceptions and IsCanceled [message #48821] Sun, 01 October 2017 13:52
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
CoWork now can handle worker thread exceptions:

#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_COUT|LOG_FILE);
	
	try {
		CoWork co;
		co & [] { throw "Worker exception"; };
	}
	catch(const char *s) {
		LOG("Caught: " << s);
	}
}


Cancelation of CoWork is now propagated to worker threads via "IsCanceled" static method:

#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_COUT|LOG_FILE);

	CoWork co;
	for(int i = 0; i < 50; i++)
		co & [] {
			for(;;) {
				if(CoWork::IsCanceled()) {
					LOG("CoWork is canceled");
					return;
				}
				Sleep(1);
			}
		};
	Sleep(100);
	co.Cancel();
}
Previous Topic: WebSocket refactored
Next Topic: ArrayCtrl::Column lambda cleanup
Goto Forum:
  


Current Time: Thu Mar 28 18:32:01 CET 2024

Total time taken to generate the page: 0.01209 seconds