### Method

# GLib Source attach

#### Declaration [src]

    guint
    g_source_attach (
      GSource* source,
      GMainContext* context
    )

#### Description [src]

Adds a `GSource` to a `context` so that it will be executed within that context.

Remove it by calling `g_source_destroy()`.

This function is safe to call from any thread, regardless of which thread the `context` is running in.

#### Parameters

`context`

  Type: `GMainContext`

  A main context (if `NULL`, the global-default main context will be used).

  The argument can be `NULL`.
  The data is owned by the caller of the method.

#### Return value

Type: `guint`

The ID (greater than 0) for the source within the `GMainContext`.