I have a pretty good grasp on how to use the System.ComponentModel.BackgroundWorker, basically you have a single “DoWork” function and usually some loop that does work and each iteration you check e.Cancel to determine whether or not to break and stop the loop to end the BackgroundWorker‘s “DoWork” (this all assumes the WorkerSupportsCancellation property is set correctly to true).
What I’m not sure about is if I have a recursive function (the exact function doesn’t matter, any recursive function let’s say the classic compute factorials) that performs my task (rather than a loop) how can I call this from inside a “DoWork” function, and how do I propagate up the e.Cancel up in this case to bail out on the recursion?
Do you mean something like this? As soon as the cancel is initiated the recursive loop will unroll till the top and you are stopped.