Currently I have a background thread that does some periodic heavy data management. Because it only needs to run its process every few hundred milliseconds I call Thread.Sleep()
at the end of the process and it then goes back to the top of the loop and repeats.
This is all working perfectly and doesn't cause any grief or performance issues for the rest of the software. The only thing that does bug me though is that when I break the debugger instead of going to my main threads current location, it gets stolen by the Thread.Sleep()
and takes me there instead.
Is there any way that I can disable the debugger from stopping on that line, or is there an alternative to putting the Thread to sleep?
Thanks in advance!
One thing you could try is to put the Thread.Sleep()
in a method and add the DebuggerStepThrough on it.
You can also just "freeze" the you don't want to "steal focus" from Threads window (Debug -> Windows -> Threads). Also remember to unfreeze them when you're done
As an aside using a Timer (there are two) or a AutoReset Event is preferred to using Thread.Sleep()
See Is Sleep() evil?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With