Method RequireCompleted
RequireCompleted<T>(Task<T>, string)
Reads the result of a task that must already be complete, and fails loudly instead of waiting when it is not.
This is the "assert, do not block" companion to the counted doors above. It exists for the few
synchronous entry points that are documented as never yielding — ContentDB.EnsureAssetsLoaded
reads local files in the editor and on desktop, and returns before reaching this on a platform where
a read would become a web request. Blocking there would be the very hang the invariant exists to
prevent, so an incomplete task is a broken contract and must surface as one. (The result is read only
after IsCompleted, which is why this is not a blocking read — it is the safe idiom, not an
escape from the rule.)
public static T RequireCompleted<T>(Task<T> task, string context)
Parameters
Returns
- T
Type Parameters
T