The reason the time loop worked with Dormammu was because he had no idea what time was. That he was freaked out by it, that it was the first thing he couldn't control, was what made him panic and want to deal to get out of it. Thanos had 4 Infinity Stones...even if he was stuck in a time loop, he'd find a way to use them (namely the Reality Stone) to get out of it.