Multi-threading with GTK

I have a GTK4 application with a thread stably running in the background. What is the most convenient, responsive and cleanest way for the background thread to send a signal from time to time to the main GTK thread without making it crash?

Call g_idle_add() from the background thread.

@baedert

Thank you, Timm. Just to be sure, you mean that the background thread, the one that is not running the GTK event loop, can safely call g_idle_add(), and the callback function will be run in the GTK thread? Did I get it correctly?

Yes, that is correct.

1 Like

Thank you, Timm. It works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.