init_async


Description:

public virtual async bool init_async (int io_priority = DEFAULT, Cancellable? cancellable = null) throws Error

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 Initable you can optionally call init instead.

This method is intended for language bindings. If writing in C, new_async should typically be used instead.

When the initialization is finished, callback will be called. You can then call init_async.end 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 g_io_error_cancelled will be returned. If cancellable is not null, and the object doesn't support cancellable initialization, the error g_io_error_not_supported will be returned.

As with Initable, if the object is not initialized, or initialization returns with an error, then all operations on the object except @ref and unref are considered to be invalid, and have undefined behaviour. They will often fail with critical or warning, but this must not be relied on.

Callers should not assume that a class which implements AsyncInitable can be initialized multiple times; for more information, see 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 Initable interface, the default implementation of this method will run the init function in a thread, so if you want to support asynchronous initialization via threads, just implement the AsyncInitable interface without overriding any interface methods.

Parameters:

this

a AsyncInitable.

io_priority

the I/O priority of the operation

cancellable

optional Cancellable object, null to ignore.

callback

a TaskReadyCallback to call when the request is satisfied

user_data

the data to pass to callback function