task::get Method

Returns the result this task produced. If the task is not in a terminal state, a call to get will wait for the task to finish. This method does not return a value when called on a task with a result_type of void.

_ReturnType get() const;

void get() const;

Return Value

The result of the task.


If the task is canceled, a call to get will throw a task_canceled exception. If the task encountered an different exception or an exception was propagated to it from an antecedent task, a call to get will throw that exception.


In a Windows Store app, do not call concurrency::task::wait or get (wait calls get) in code that runs on the STA. Otherwise, the runtime throws concurrency::invalid_operation because these methods block the current thread and can cause the app to become unresponsive. However, you can call the get method to receive the result of the antecedent task in a task-based continuation because the result is immediately available.


Header: ppltasks.h

Namespace: concurrency

See Also


task Class (Concurrency Runtime)