I am facing this odd issue in which GUI freezes randomly on button clicked
So basically This is the sample code:
`void dialog::OnButton1Clicked()
{
m_threadCmd = Button1; //Button1 is an enum from commandEnumList
AfxBeginThread(ui_ThreadExecuteCmd, this);
}
UINT dialog::ui_ThreadExecuteCmd()
{
OWaitCursor waitCursor;
switch (this->m_threadCmd)
{
case BUTTON1:
if (!Func1())
{
ShowError();
}
break;
}
this->m_threadCmd = 0;
return 0;
}
bool Func1()
{
//Notify GUI via PostMessage to disable the controls in the main thread
//Do some processing
//Notify GUI via PostMessage to enable the controls in the main thread
//return errorcode
}`
The weird thing is that sometime it works fine and sometimes the GUI freezes.
I am seeing the UI buttons getting disabled then performing the operation -then ui buttons getting enabled back again. The Gui freeze happens randomly after that and when it freezes the buttons become unclickable and i am not receiving any message in PreTranslateMsg() after the freeze for mouse click or anything else
Added logs to check if there is some deadlock happening, but does not seem so. Every function is getting hit and executed in the sequence that it needs to be. Still the GUI freeze happened.
ZeeUd25 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1