MainContext.invoke

Invokes a function in such a way that @context is owned during the invocation of @function.

If @context is %NULL then the global default main context — as returned by g_main_context_default() — is used.

If @context is owned by the current thread, @function is called directly. Otherwise, if @context is the thread-default main context of the current thread and g_main_context_acquire() succeeds, then @function is called and g_main_context_release() is called afterwards.

In any other case, an idle source is created to call @function and that source is attached to @context (presumably to be run in another thread). The idle source is attached with #G_PRIORITY_DEFAULT priority. If you want a different priority, use g_main_context_invoke_full().

Note that, as with normal idle functions, @function should probably return %FALSE. If it returns %TRUE, it will be continuously run in a loop (and may prevent this call from returning).

class MainContext
void
invoke

Parameters

function_ GSourceFunc

function to call

data void*

data to pass to @function

Meta

Since

2.28