"Watch Dog" or sandbox system in c#
I have a function that I want to allow to run for a given length of time and then, if it hasn't quit on it's own, about. *What is the best way to do this?*

The best I have thought of would be to run it in another thread, wait with a timeout for it to die and then use `Thread.Abort()` to kill it (this might not work if the function has the wrong kind of `catch` block). Another option (one that I don't know how to make work) would be some kind of preemptive timer with a throw in it.

*Is there a better way? Some kind of easy sandbox system?*
"Watch Dog" or sandbox system in c#
===

I have a function that I want to allow to run for a given length of time and then, if it hasn't quit on it's own, about. *What is the best way to do this?*

The best I have thought of would be to run it in another thread, wait with a timeout for it to die and then use `Thread.Abort()` to kill it (this might not work if the function has the wrong kind of `catch` block). Another option (one that I don't know how to make work) would be some kind of preemptive timer with a throw in it.

*Is there a better way? Some kind of easy sandbox system?*