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 MainContext.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 MainContext.acquire succeeds, then function is called and MainContext.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 MainContext.invokeFull.

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