The best way is to not have a timeout.
TDR is covered at the following MSDN article: http://msdn.microsoft.com/en-us/Library/Windows/Hardware/ff570088%28v=vs.85%29.aspx and is discussed in some detail, including the reasons for it, how it operates, and which registry keys control it.
You can certainly extend the TDR interval beyond the default 2 seconds, but Microsoft themselves advise that:
You can use the following TDR-related registry keys for testing or debugging purposes only. That is, they should not be manipulated by any applications outside targeted testing or debugging.
In other words, fix whatever is causing a TDR during your testing and ship your program without TDRs.
The reason is that the behaviour is by design: it's to assist with misbehaving programs or drivers that lock up the GPU and cause an unresponsive system. By issuing a TDR the OS will at least be returned to the user in an actual usable state and without requiring a hard reboot.
So if you're getting TDRs you've either (1) got a bad driver, or (2) are doing something that takes an abnormally long time.