Other than setting a debug variable and incrementing it every time you start the foreach, when you break in with the Visual Studio debugger connected, is there a way to tell that this is the Xth time through the loop?
I guess this would be a feature of Visual Studio if anything, not something that would be added to the compiled code.
Heres a previous Stack Overflow question that seems to be what your looking for:
get-index-of-current-foreach-iteration
Answer quoted from that link: