AsyncInitable.initAsync

Starts asynchronous initialization of the object implementing the interface. This must be done before any real use of the object after initial construction. If the object also implements #GInitable you can optionally call gio.initable.Initable.init_ instead.

This method is intended for language bindings. If writing in C, gio.async_initable.AsyncInitable.newAsync should typically be used instead.

When the initialization is finished, callback will be called. You can then call gio.async_initable.AsyncInitable.initFinish to get the result of the initialization.

Implementations may also support cancellation. If cancellable is not null, then initialization can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error gio.types.IOErrorEnum.Cancelled will be returned. If cancellable is not null, and the object doesn't support cancellable initialization, the error gio.types.IOErrorEnum.NotSupported will be returned.

As with #GInitable, if the object is not initialized, or initialization returns with an error, then all operations on the object except gobject.object.ObjectG.ref_ and gobject.object.ObjectG.unref are considered to be invalid, and have undefined behaviour. They will often fail with g_critical() or g_warning(), but this must not be relied on.

Callers should not assume that a class which implements #GAsyncInitable can be initialized multiple times; for more information, see gio.initable.Initable.init_. If a class explicitly supports being initialized multiple times, implementation requires yielding all subsequent calls to init_async() on the results of the first call.

For classes that also support the #GInitable interface, the default implementation of this method will run the gio.initable.Initable.init_ function in a thread, so if you want to support asynchronous initialization via threads, just implement the #GAsyncInitable interface without overriding any interface methods.

interface AsyncInitable
void
initAsync

Parameters

ioPriority int

the [I/O priority][io-priority] of the operation

cancellable gio.cancellable.Cancellable

optional #GCancellable object, null to ignore.

callback gio.types.AsyncReadyCallback

a #GAsyncReadyCallback to call when the request is satisfied