# Tasks and delayed work

task starts a named function asynchronously, can carry a typed result, and can be delayed with after.

Last updated: 2026-09-09

Package: language | Status: experimental

Tags: after, await, concurrency, cpu, language, of, task, yeho

Use a task when useful work can progress independently and you can define completion, failure, cancellation, and ownership.

```yh
task name = task Work()
task of Type name = task Work()
task name = task after 100ms Work()
await name
```


## Complete tasks and delayed work example

Use a task when useful work can progress independently and you can define completion, failure, cancellation, and ownership.

Verification: type checked

```yh
Score() -> int { return 40 + 2 }
task of int job = task Score()
wait job
if job.failed { Console.Error(job.error.message) }
else { Console.Log(Text.From(job.result)) }

```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.language__tasks"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

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/language--tasks/complete --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Task, parallel, and tunnel behavior varies by target and remains experimental.

Do not discard a task unless its lifecycle and failure are intentionally unobserved.

Source: yeho/errors-tasks-effects-2026.1.json; tests/compiler/errors-tasks-effects/task-lifecycle/start.yh

AI training permission: https://demonhunterlabs.com/ai-use
