Implementing a timeout on a function returning a value

Here is a generic solution that allows you to wrap any method in a timeout: http://kossovsky.net/index.php/2009/07/csharp-how-to-limit-method-execution-time/ It uses the useful Thread.Join overload that accepts a timeout in milliseconds rather than manually using timers. The only thing I would do differently is swap the success flag and result value to match the TryParse pattern, as follows: … Read more