I am experimenting a bit with Thread programming in upp and encountered an error.
The compiler did not recognize the thread class name.
The example GUIMT runs without errors from which I took most of the code, but my application does not recognize the thread class.
class MyClass : public WithMyClassLayout<TopWindow>
{
public:
typedef MyClass CLASSNAME;
MyClass();
void StartPlay();
//thread handling
volatile Atomic terminated;
volatile Atomic threads;
};
typedef struct {
MyClass *gui;
} PlayInfo;
//thread callback
void WorkerThread(PlayInfo f)
{
while (true)
{
if(f.gui->terminated)
break;
//playfile
}
AtomicDec(f.gui->threads);
}
//Callback of button
void MyClass::StartPlay()
{
PlayInfo f;
f.gui = this;
AtomicInc(threads);
Thread().Run(callback1(WorkerThread, f));//error in this line
}
Output:
error C2228: Left of ".Run" has to be a class/struct/union
Typ is ''unknown-type''
error C3861: "Thread": Identifier was not found.
Thank you for comments and help
Hello Reini
I can answer you with a 99,999% of possibilities that the problem comes from you have not included in "Project/Main package configuration" the option MT (multi thread).
Reini Messages: 28 Registered: April 2009 Location: Berlin
Promising Member
Hello Koldo
Thanks for your help ! It worked
But anyway it was way complicated to activate the MT Flag in an already existing project since I did not found a possibility to acitvate the MT switch if the project already exists.
So I had to do that manually in the upp Project File and then only it worked.
cbpporter Messages: 1427 Registered: September 2007
Ultimate Contributor
Why was it hard? "Project/Main package configuration" as said above, press Insert or right click and select menu to insert a new configuration, an type MT there. Or if you have already a configuration, you can add it to that.
Why was it hard? "Project/Main package configuration" as said above, press Insert or right click and select menu to insert a new configuration, an type MT there. Or if you have already a configuration, you can add it to that.