Package: gio

Function gio:task-new

Lambda List

gio:task-new (source cancellable func)

Arguments

source -- a g:object instance that owns this task, or nil
canellable -- an optional g:cancellable instance, nil to ignore
func -- a g:async-ready-callback callback function

Return Value

A g:task instance.

Details

Creates a g:task instance acting on source, which will eventually be used to invoke callback in the current thread-default main context.

Call this in the "start" method of your asynchronous method, and pass the g:task instance around throughout the asynchronous operation. You can use the g:task-set-task-data function to attach task-specific data to the object, which you can retrieve later via the g:task-get-task-data function.

By default, if cancellable is cancelled, then the return value of the task will always be G_IO_ERROR_CANCELLED, even if the task had already completed before the cancellation. This allows for simplified handling in cases where cancellation may imply that other objects that the task depends on have been destroyed. If you do not want this behavior, you can use the g:task-set-check-cancellable function to change it.
 

See also

#2023-7-13