I am looking for good ideas for implementing a generic way to have a single line (or anonymous delegate) of code execute with a timeout.
TemperamentalClass t
What about using Thread.Join(int timeout)?
public static void CallWithTimeout(Action act, int millisecondsTimeout) { var thread = new Thread(new ThreadStart(act)); thread.Start(); if (!thread.Join(millisecondsTimeout)) throw new Exception("Timed out"); }