Everyone knows thread should exit gracefully, but now I have to kill a thread.
When there is a request comming, I start a thread as below
_thread = new Thread(ProcessTemplate);
_thread.Start();
In the ProcessTemplate
method, it takes use of Google V8 to compile and run a javascript code sent from client-side.
The problem is, the javascript sent from client-side could be buggy and cause an infinite loop.
Hence, I count the time since the thread start and if the javasctript execution time exceeds 10 second, I kill the thread like
try
{
_thread.Abort();
}
catch
{
}
It works but also affects the current thread which started the _thread. I receive "Thread was being aborted." exception from current thread.
how to avoid/ignore the exception?