user46573544 user46573544 - 6 months ago 82
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

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.