for (APCounter = start; APCounter < Stager.InstructionsMemory.Length; APCounter++)
{
PipelineInitializor();
int i1 = APCounter;
int i = APCounter;
tasks[i] = new BlockingCollection<Func<object>>();
tasks[i].Add(() => Fetch(i1));
tasks[i].Add(() => Decode(i1));
tasks[i].Add(() => ALURes(i1));
tasks[i].Add(() => Memory(i1));
tasks[i].Add(() => WriteB(i1));
InstructionThread[i] = new Thread(() => Worker(i1, tasks[i1]));
InstructionThread[i1].Start();
}
Those are couple of threads that needs to be replaced by new threads that carry same kind of data object, but with new tasks data.
I’ve tried using the Abort method (which is not recommended), and it caused everything to halt execution, and no matter what function I call, nothing starts execution again.
I would suggest you use the Task Parallel Library and the Task class, it has the capability of
cancellation.
“Replacing” a thread doesn’t make any sense. You can start a new thread to process the same data; but, if you have no way for the other thread to stop itself you can’t reliably stop it.