Search code examples
c++wxwidgets

fill high data in wxListCtrl using wxThread- i can but


i want to fill database table in wxListCtrl, i can do this , i m using wxThread for this. my problem is - my concept is working for small amount of data, when i increase the size, it shows a error like-

showingdatainwxlistctrl: ../../src/XlibInt.c:595: _XPrivSyncFunction: Assertion `dpy->synchandler == _XPrivSyncFunction' failed.

my code is given below:-

void *MyThread :: Entry()
{
    int i=1,j,k=0   ;
    while(i!=400)
    {
        long index=this->temp->data_list_control->InsertItem(i,wxT("amit"));

        for(j=1;j<3;j++)
        {
            this->temp->data_list_control->SetItem(index,j,wxT("pathak"));    
        }
        k++;
        if(k==30)
        {
            this->Sleep(1000);
            k=0;
        }
        i++;    
    }
}

if i used i =4, 10 100, it is working but i crossed the limit( i dont know at which point) it start showing error if you have any suggestion then pls help me...


Solution

  • Instead of direct SetItem call from the worker thread, you need to post event to the main thread and add item in the event handler. Data for list control event should be placed to custom event class. See details in wxPostEvent function and here: http://wiki.wxwidgets.org/Custom_Events