user46573544 user46573544 - 1 year ago 364
C Question

How to use g_timeout_add?

I am making a program in C with GTK and Glade for a serial communication. I am having problem using g_timeout_add. For example I have a function

which contain my serial data and I have a button handler
. So till now I have done that if
update button
is clicked,
should run. But it running just for one time.

on_update_button_clicked(GtkButton *Update_Button)
//2nd argument is serial_data function which contain actual data

where I am missing the point?

I have another button
stop button
. So i want that
should stop when
stop button handler
is clicked. How to do that.??

One more question to ask, I want to count the number of times
is running like a counter. So that I can display the numbers of counter. How is this possible.?
Please help thanks.

jku jku
Answer Source

g_timeout_add() returns an event source id that you should store. You can use g_source_remove() with that id in your stop button handler to stop the timeout.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download