Did you ever set a breakpoint within BackgroundWorker execution (worker thread), hit it and then application would stall. It is certainly a strange behavior.
Apparently the problem happens because debugger calls into ToString() of the BackgroundWorker’s host (which is usual a Form derived class) and this call doesn’t happen in the same thread as host was created (remember, never touch UI controls from non-creation threads). This situation yields unpredictable results, normally application just doesn’t respond anymore. The cause and the workarounds to this annoyance is described in this blog post. Basically you have three possibilities:
- No more calls into ToString()
- Disable func eval entirely (ouch)
- Avoid the problem
I choose to go with the point 1. and it works for me. Point 2 is the worst choice.
I hope that debugger folks will do something regarding this issue in the future as it makes you wonder what is going on until you find the description.