Re: thread blocks/freezes the main gui
- From: Bob Caryl <bob fis-cal com>
- To: Bob Caryl <bob fis-cal com>
- Cc: Anca Mitrica <ancamitrica yahoo com>, gtkmm-list gnome org
- Subject: Re: thread blocks/freezes the main gui
- Date: Mon, 15 Aug 2005 09:56:35 -0500
Sorry, my mistake: meant to write Glib::Thread::join instead of
Gtk::Thread::join.
Bob
Bob Caryl wrote:
Your call to Gtk::Thread::join (shown below)
void MainPage::envoyer_directive_courrante(){
//envoit une directive au bvl_serveur
send_dir_thread =
Glib::Thread::create(sigc::mem_fun(*this,&MainPage::ecrire_entree_standard),true);
send_dir_thread->join();
}
will wait until the joined thread terminates before returning; hence,
all processing in your main window stops.
Bob Caryl
Anca Mitrica wrote:
Hello,
I am writing an application that communicates, between
others, with another program (server) through pipes.
My application has a textview and a button that sends
the textview content to the server.
The communication is made via a thread wich writes to
the standard input of the server the textview content.
The server is run with g_spawn_async_with_pipes.
Somehow, the writing thread is blocking the main user
interface, that must be active all the time. Can
anyone has an idea??
The code is the following:
//the button function
...........................................................
//run the server
g_spawn_async_with_pipes(NULL,argv,NULL,(GSpawnFlags)(G_SPAWN_DO_NOT_REAP_CHILD),NULL,NULL,
&stat_autochildpid,&childstdin,&childstdout,&childstderr,&error)){
//sauver le pid du processus bvl_serveur
save_auto_pid(stat_autochildpid);
//attends que le processus se termine
g_spawn_close_pid(stat_autochildpid);
}
envoyer_directive_courrante();
..................................................
//envoyer_directive_courrante function
void MainPage::envoyer_directive_courrante(){
//envoit une directive au bvl_serveur
send_dir_thread =
Glib::Thread::create(sigc::mem_fun(*this,&MainPage::ecrire_entree_standard),true);
send_dir_thread->join();
}
...........................................
//function for the thread
void MainPage::ecrire_entree_standard(){
line_to_send = *stat_diriterator;
line_to_send.erase(0,line_to_send.find_first_of(",",0)+1);
Glib::RefPtr<Glib::IOChannel> in_channel =
Glib::IOChannel::create_from_fd(childstdin);
in_channel->write(line_to_send);
//in_channel->close();
/* for(unsigned int i = 0;i<line_to_send.size();i++){
cout<<line_to_send[i];
}
cout<<endl; */
//stat_diriterator++;
}
Anca Mitrica
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com _______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]