Camel.AsyncClosure
Description: Reference for Camel.AsyncClosure

### Struct

# CamelAsyncClosure

since: 3.12

#### Description [src]

    struct CamelAsyncClosure {
      /* No available fields */
    }

Run asynchronous functions synchronously.

`CamelAsyncClosure` provides a simple way to run an asynchronous function synchronously without blocking the current thread.

1) Create a `CamelAsyncClosure` with camel_async_closure_new().

2) Call the asynchronous function passing `camel_async_closure_callback()` as the `GAsyncReadyCallback` argument and the `CamelAsyncClosure` as the data argument.

3) Call `camel_async_closure_wait()` and collect the `GAsyncResult`.

4) Call the corresponding asynchronous “finish” function, passing the `GAsyncResult` returned by camel_async_closure_wait().

5) If needed, repeat steps 2-4 for additional asynchronous functions using the same `CamelAsyncClosure`.

6) Finally, free the `CamelAsyncClosure` with camel_async_closure_free().

Available since: 3.12

#### Functions

###### camel_async_closure_callback

Pass this function as the `GAsyncReadyCallback` argument of an asynchronous function, and the `CamelAsyncClosure` as the data argument.

since: 3.12

###### camel_async_closure_new

Creates a new `CamelAsyncClosure` for use with asynchronous functions.

since: 3.12

#### Instance methods

###### camel_async_closure_free

Frees the `closure` and the resources it holds.

since: 3.12

###### camel_async_closure_wait

Call this function immediately after starting an asynchronous operation. The function waits for the asynchronous operation to complete and returns its `GAsyncResult` to be passed to the operation’s “finish” function.

since: 3.12