{"id":"language--tasks","name":"Tasks and delayed work","owner":"yeho","package":"language","kind":"language","signature":"task name = task Work()\ntask of Type name = task Work()\ntask name = task after 100ms Work()\nawait name","description":"task starts a named function asynchronously, can carry a typed result, and can be delayed with after.","context":"Use a task when useful work can progress independently and you can define completion, failure, cancellation, and ownership.","parameters":[],"returns":"","members":[],"tags":["after","await","concurrency","cpu","language","of","task","yeho"],"updated":"2026-09-09","source":{"repository":"yeho","path":"errors-tasks-effects-2026.1.json; tests/compiler/errors-tasks-effects/task-lifecycle/start.yh"},"status":"experimental","notes":["Task, parallel, and tunnel behavior varies by target and remains experimental.","Do not discard a task unless its lifecycle and failure are intentionally unobserved."],"examples":[{"id":"complete","title":"Complete tasks and delayed work example","description":"Use a task when useful work can progress independently and you can define completion, failure, cancellation, and ownership.","code":"Score() -> int { return 40 + 2 }\ntask of int job = task Score()\nwait job\nif job.failed { Console.Error(job.error.message) }\nelse { Console.Log(Text.From(job.result)) }\n","tags":["cpu","language"],"run":"cpu-oracle","expected":null,"verifyRun":false,"manifest":"manifestVersion = \"2\"\npackage = \"api.example.language__tasks\"\nversion = \"0.1.0\"\nlanguageEdition = \"yeho-core-2026.1\"\n\n[app]\nkind = \"headless\"\n","verification":"type checked","sha256":"2c6bd275b2fe03ae95eb55c2f0602a56e07ded4aec4b71f08d12d53401175be6","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=language--tasks","json":"https://demonhunterlabs.com/reference/items/language--tasks.json","markdown":"https://demonhunterlabs.com/reference/text/language--tasks.md"}
