Share via


task_completion_event::set_exception Method

Propagates an exception to all tasks associated with this event.

bool set_exception(
   std::exception_ptr _ExceptionPtr
) const ;

Parameters

  • _ExceptionPtr
    The exception_ptr that indicates the exception to set this event with.

Return Value

The method returns true if it was successful in setting the exception. It returns false if the task_completion_event already has a value or an exception.

Remarks

Both set and set_exception can be called multiple times. When a value or an exception have already been set on the task_completion_event, a call to set_exception fails and returns false. Otherwise, the call succeeds and the function returns true. When an exception is set successfully on a task_completion_event, that exception must be explicitly observed by the user. This can be done by calling a get on a task created from the task_completion_event, or by calling a get on the antecedent task in a task-based continuation of that task.

Requirements

Header: ppltasks.h

Namespace: concurrency

See Also

Reference

task_completion_event Class