Prev: ANN: wxWidgets 2.7.2 released - linking problem with MSYS (mingw)on Windows XP
Next: When can you trust a window size?
From: Eric Laly on 9 Nov 2006 15:09 I'm launching a thread with a click on a button "encadrer" If the user wants to cancel the operation, he clicks on a button "annuler" (cancel) to ask the (joinable) thread to terminate. The code is at the end of the message. When this code is running under Linux: no problem But when running under Windows there is an error when clicking on button "annuler". Sometimes the thread stops, sometimes not but there is always this messages: "couldn't terminate thread (error 6: descripteur non valide)" and "can not wait for thread termination (error 6: descripteur non valide)" Someone can help ? Thanks in advance. ?ric Laly. ------the creation of the thread when clicking on button "encadrer": void PanelResultat::on_click_button_encadrer(wxCommandEvent& event) { ... // on cr?e le thread de lecture des codes-barres Thread_traitement = new ThreadTraitement(panel_cadres,panel_signature,panel_choix_images,panel_parametres_sortie,this); if ( thread_traitement->Create() != wxTHREAD_NO_ERROR ) { wxLogFatalError(wxT("Cr?ation thread traitement impossible!")); } else { thread_traitement->Run(); } } ------The constructor of ThreadTraitement (joinable type): ThreadTraitement::ThreadTraitement(...) : wxThread(wxTHREAD_JOINABLE) -------The end of the thread when clicking on button "annuler": void PanelResultat::on_click_button_annuler(wxCommandEvent& event) { if (wxMessageBox(wxT("Voulez-vous vraiment interrompre le traitement ?"),wxT("Encadre_Image"),wxYES_NO|wxICON_QUESTION)==wxYES) { // on demande au thread de traitement de se terminer thread_traitement->Delete(); // et on attend sa fin thread_traitement->Wait(); ... } } ------And the "job" in the thread: for (unsigned int i=0;i<liste_images.size();i++) { ... if (TestDestroy()) Exit(0); ... } --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org |