gthread problem



Hi,

I use gthread.
And in the thread loop, I want to show message box.
like this...

--------thread function--------------------------------------------
void* thread_func( void* arg ){
    while(1){
        sleep( _Ini.GetCduFcheckTime() );

        //end check
        if ( m_end == 1 )
                break;

        //check file
        rc = my_file_check( msg );

        //end check
        if ( m_end == 1 )
                break;

        //msg
        if ( rc == COM_OK ){
            //update main list <- is here problem??
            gdk_threads_enter();
            my_make_lst(m_lst);
            gdk_threads_leave();

            //msg box <- make err!!
            msgOkOnly( msg );
        }

        //end check
        if ( m_end == 1 )
                break;
    }
}

-------------msg box function-------------------------------------
void    msgOkOnly( char*   msg )
{
    //create msg box porc
            :
            :

    //show dialog
    gdk_threads_enter();
    gtk_widget_show( dlg );
    gdk_threads_leave();

    return;
}
------------main function-----------------------------------------
main(){
    //create window proc
        :
        :

    //thread create
    pthread_create(&tid, NULL, thread_func, NULL);
    m_end = 2;

    makeLst(m_lst);

    //show dlg
    gtk_widget_show( m_wnd );

    //main
    gdk_threads_enter();
    gtk_main();
    gdk_threads_leave();
}
------------------------------------------------------------------

Sometimes it's success, but sometimes it makes error.
The error is occured in thread proc at msg box function.

The error is......
    Glib-WARNING **: g_main_iterate(): main loop already active
    in another thread
......

Exactly, the main loop is in main function.
But there is thread, and I need to show msg box from thread loop.

Is there someting to solution ? or Is there good sample source?
Please teach me..







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]