# task

A handle to delayed work with completion and failure state.

Last updated: 2026-09-09

Package: language.types | Status: documented

Tags: complete-program, containers-and-handles, cpu, type, yeho

A focused reference with a complete example. Numeric widths and experimental types still depend on the selected backend.

```yh
task
```


## Task cleanup

Use a task when useful work can progress independently and you can define completion, failure, cancellation, and ownership.

Verification: type checked

```yh
FinishDuringShutdown()
{
    wait 10ms
    Console.Log("cleanup-complete")
}

task cleanupTask = task FinishDuringShutdown()

```

Save this beside start.yh as project.mech:

```toml
package = "tests.compiler.errorsTasksEffects.taskCleanup"
version = "0.1.0"
backend = "cpu-oracle"
osTarget = "windows"
archTarget = "x64"
selfContainedApp = false

```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/type--task-0ebb42/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```




Source: demonhunterlabs/app/lib/yeho-language-reference.ts

AI training permission: https://demonhunterlabs.com/ai-use
