Share via


agent::wait Method

Waits for an agent to complete its task.

_CRTIMP2 static agent_status __cdecl wait(
   agent * _PAgent,
   unsigned int _Timeout = COOPERATIVE_TIMEOUT_INFINITE
);

Parameters

  • _PAgent
    A pointer to the agent to wait for.

  • _Timeout
    The maximum time for which to wait, in milliseconds.

Return Value

The agent_status of the agent when the wait completes. This can either be agent_canceled or agent_done.

Remarks

An agent task is completed when the agent enters the agent_canceled or agent_done states.

If the parameter _Timeout has a value other than the constant COOPERATIVE_TIMEOUT_INFINITE, the exception operation_timed_out is thrown if the specified amount of time expires before the agent has completed its task.

Requirements

Header: agents.h

Namespace: Concurrency

See Also

Reference

agent Class

agent::wait_for_all Method

agent::wait_for_one Method

agent_status Enumeration