Home » U++ Library support » U++ Widgets - General questions or Mixed problems » ASSERT(IsMainThread());
ASSERT(IsMainThread()); [message #21420] |
Tue, 19 May 2009 13:56  |
|
Hello Mirek!
I have an error on run a builded application in line
from uppsrc/Ctrl/CtrlCore/Win32Wnd.cpp in method void Ctrl::GuiSleep(int ms) .
What i do wrong? some days ago works fine, but after you added this line its prompt error! Tell me how can I change my code?
The situation is: I call a function in a thread instance, and this function works with GUI (progress). I uses this in GoogleTranslator that I call function in thread for translate a text
this is full method:
void Ctrl::GuiSleep(int ms)
{
GuiLock __;
=>HERE ASSERT(IsMainThread());
ELOG("GuiSleep");
if(EndSession())
return;
ELOG("GuiSleep 2");
int level = LeaveGuiMutexAll();
#if !defined(flagDLL) && !defined(PLATFORM_WINCE)
if(!OverwatchThread) {
DWORD dummy;
OverwatchThread = CreateThread(NULL, 0x100000, Win32OverwatchThread, NULL, 0, &dummy);
ELOG("ExitLoopEventWait 1");
ExitLoopEvent().Wait();
}
HANDLE h[1];
*h = ExitLoopEvent().GetHandle();
ELOG("ExitLoopEventWait 2 " << (void *)*h);
MsgWaitForMultipleObjects(1, h, FALSE, ms, QS_ALLINPUT);
#else
MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT);
#endif
EnterGuiMutex(level);
}
Add:
I added GoogleTranslator as example.
After build and run application press Translate button for generate error!
[Updated on: Tue, 19 May 2009 17:11] Report message to a moderator
|
|
|
|
Re: ASSERT(IsMainThread()); [message #21427 is a reply to message #21425] |
Tue, 19 May 2009 19:06   |
|
luzr wrote on Tue, 19 May 2009 18:45 | Well, I have fixed this, although I am not quite sure if there is any good use to call GuiSleep from non-main thread:
GuiSleep waits at most given time, but waiting stops if there are any input events (like MouseDown) to be processed. Anyway, processing messages is always performed by the main thread, so it is questionable why is GuiSleep good for non-mains.
Mirek
|
In base my example what is the solution?
|
|
|
|
Goto Forum:
Current Time: Sun Apr 27 22:14:21 CEST 2025
Total time taken to generate the page: 0.01174 seconds
|