Home » Community » U++ community news and announcements » CoWork exceptions and IsCanceled
CoWork exceptions and IsCanceled [message #48821] |
Sun, 01 October 2017 13:52 |
|
mirek
Messages: 13976 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();
}
|
|
|
Goto Forum:
Current Time: Fri May 10 01:05:05 CEST 2024
Total time taken to generate the page: 0.03378 seconds
|