Search code examples
c#multithreadingvisual-studiodebuggingstep-into

During debug, step into background worker/thread. Possible?


Out of curiosity. I'd like to know if its possible to step into (F11) a background worker during debugging. It usually just skips over to the next line of code. Is it a VS setting that needs to be changed? Is it just how its meant to be?

Any clarification would be much appreciated. Thanks.


Solution

  • It usually just skips over to the next line of code.

    That's because the BackgroundWorker is being executed on a different thread, which has to be created and started first, and this takes some time. If you keep stepping, you will enter the worker at some point, but there's no telling when exactly.

    Just put a breakpoint at the start of the worker code if you want to debug it.