【MSCE C++ U12】新的工作线程如何读取ma资源文件的字符串资源?

在主线程 MdlMain函数中测试读取ma文件中的资源没有问题。

但在新开线程关联的outputMsg函数无法读取资源。

不知用何办法解决?谢谢老师。

void outputMsg()
{
WString outMsg;
mdlResource_loadWString(outMsg, 0, STRINGLISTID_Prompts, 1);
mdlResource_loadWString(outMsg, 0, STRINGLISTID_Prompts, 2);
}

extern "C" void MdlMain(int argc, WCharCP argv[])
{

RscFileHandle rfHandle;
mdlResource_openFile(&rfHandle, NULL, RSC_READ);
mdlSystem_registerCommandNumbers(s_commandNumbers);

if (mdlParse_loadCommandTable(NULL) == NULL)
mdlOutput_rscPrintf(MSG_ERROR, NULL, STRINGLISTID_Messages, MSGID_CommandTable);

mdlState_registerStringIds(STRINGLISTID_Commands, STRINGLISTID_Prompts);

//下面测试没有问题,能读取资源

WString outMsg;
mdlResource_loadWString(outMsg, 0, STRINGLISTID_Prompts, 1);
mdlDialog_dmsgsPrint(outMsg.GetWCharCP());
mdlResource_loadWString(outMsg, 0, STRINGLISTID_Prompts, 2);
mdlDialog_dmsgsPrint(outMsg.GetWCharCP());

//

//下面新开线程关联的outputMsg函数无法读取资源

std::thread t(outputMsg);

if (t.joinable())
t.join();

}

Parents Reply Children
No Data