First of all, I apologize if this or a similar question was asked earlier. It seemed to be, but I could not find it.
I have a third-party assembly with the method I call, this method has parameters containing a list of objects (in concept, not List<object>) and returns the result after a potentially long algorithm.
I call this method on another thread to keep the interface responsive. And it is called quite regularly and with a different list of values. This means that it often works when I want to restart it. The problem is that creating a new thread is pretty naive, so every time it starts with a new one - this leads to the fact that several threads work with different input parameters. I really want all existing threads to die, as I am no longer interested in exiting them.
I am not very familiar with the advanced methods of multi-threaded processing, so I would really like some suggestions regarding the best approach to this problem.
(I use 3.5, so there is no TPL)
EDIT
I split Reflector to see what is going on inside and most of the code is marked protected, so I'm pretty sure I can inherit and terminate the call in the check to exit earlier, in accordance with the answers below.
Richk source
share