Kill a thread after a time limit
Posted on 2001-07-14
I have a program that starts a number of threads.
Each thread gets some data and does some manipulation to get a "result"
When each thread completes it sends a message to the window that started it, telling it's result.
Unfortunately there is code in the thread that very occassionally (like 1 in 10,000 times or less) can hang, and the result never comes back. I am not in a position to fix this code.
Killing the hung thread and trying the calculation again, is the best (only) way to solve this.
What I need is a SIMPLE way to kick off a thread, and if the thread hasn't completed in a set amount of time (say 30 seconds), kill it, and try again.
No MFC. C/C++ Win32 using Visual C++ v6. FWIW this stuff lives in a DLL