Dual WAN Failover on Latency

Can anyone help me with a way to failover to a secondary WAN connection based on Latency?