I am getting a database table value in wxListCtrl, (data can be large so I am using wxThread) Child thread send row to Main thread and main thread fill it in wxListCtrl, everything is going good but when I m trying to close the frame , it is giving me unexpected result. at the close button , I am invoking a new frame, sometime it opens and some time not, my code is:-
if(thread_object_holder->IsAlive())
{
wxPuts(wxT("live"));
thread_object_holder->Pause();
wxMessageDialog *msg = new wxMessageDialog(this,wxT("You want to quit"), wxT("Quit Login Report") ,wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
if ( msg->ShowModal() == wxID_YES )
{
thread_object_holder->Delete();
temp_back_frame *obj= new temp_back_frame();
this->Destroy();
obj->Show(true);
}
else
{
thread_object_holder->Resume();
}
}
else
{
wxPuts(wxT("dead"));
wxMessageDialog *msg = new wxMessageDialog(this,wxT("You want to quit"), wxT("Quit Login Report") ,wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION);
if ( msg->ShowModal() == wxID_YES )
{
thread_object_holder->Delete();
temp_back_frame *obj= new temp_back_frame();
this->Destroy();
obj->Show(true);
}
}
there are only 7 row in table, during the filling record if I press the button, everything is fine there but once 7 row placed in ListCtrl { I think now thread will be destroy } , me no data to put to listctrl, we press close button then sometime new frame open, some time frame hang, I THINK THREAD IS RESPONSIBLE FOR THIS BUT HERE I TAKE PROPER PRECAUTION TO HANDLE THE THREAD, please let me know, where I am wrong.