Can I reroute a task based on how long the client has been waiting for an agent to answer?

Is there a way to keep track of how long the customer has been waiting for a specific agent to answer? And if the client is waiting for more than XXXX amount then route them to another agent?