Feedback
Cannot store an Async function call in a Task or Task(Of T) variable
- Status
- Fixed
- Fixed in
- v26.9.4
- Area
- compiler
- Source discussion
- https://forum.objo.dev/d/1200-xecution-stops-silently-after-await-inside-select-case-finally-not-run
- Last updated
- 2026-09-28
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
Calling an Async function without Await and storing the resulting Task in a variable fails to compile. For example:
Var t1 As Task(Of DBAnswer) = client.GetRecordAsync()
fails with:
Cannot assign 'DBAnswer' to variable of type 'Task(Of DBAnswer)'.
Expected behaviour: calling an Async function yields its Task (or Task(Of T)), so it can be stored and awaited later — the documented "start now, await later" pattern. Await is what unwraps the result; the call itself must type as the task.