Re: Using threads ?



To sum my problem up, I want to :

- exec a binary in the background from my Gtk2 window
- keep an eye on the binary execution's state (running|finished or X %
complete)
- update some widgets according to the state of the binary execution




Not sure that the thread suggestion gives you any feedback other than when the application terminated.

I have not used it, but from the API description it seems that g_spawn_async_with_pipes() is exactly what you want. Assuming that the binary is a commandline program, or otherwise outputs the information that you need to standard out.

You will want to use the GLib IO monitoring on the descriptor that you get for the spawned binary's stdout, and then your callback will get called whenever there is output to be read.

Of course, if you are writing the binary, and the binary can BE the other thread, rather than BE CALLED FROM the other thread, then the situation is completely different.

Eric




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