This documentation is archived and is not being maintained.

structured_task_group::run Method

Schedules a task on the structured_task_group object. The caller manages the lifetime of the task_handle object passed in the _Task_handle parameter.

   class _Function
void run(
   task_handle<_Function>& _Task_handle


The type of the function object that will be invoked to execute the body of the task handle.


A handle to the work being scheduled. Note that the caller has responsibility for the lifetime of this object. The runtime will continue to expect it to live until either the wait or run_and_wait method has been called on this structured_task_group object.

The runtime creates a copy of the work function that you pass to this method. Any state changes that occur in a function object that you pass to this method will not appear in your copy of that function object.

If the structured_task_group destructs as the result of stack unwinding from an exception, you do not need to guarantee that a call has been made to either the wait or run_and_wait method. In this case, the destructor will appropriately cancel and wait for the task represented by the _Task_handle parameter to complete.

Throws an invalid_multiple_scheduling exception if the task handle given by the _Task_handle parameter has already been scheduled onto a task group object via the run method and there has been no intervening call to either the wait or run_and_wait method on that task group.

Header: ppl.h

Namespace: Concurrency