AI OnAI Off
Sounds like you're hitting the code from different threads. Compare System.Threading.Thread.CurrentThread.ManagedThreadId between the two. Are there multiple (possibly simultaneous) calls to GetImages triggered from the same request? There are ways to cope with this situation using conditional breakpoints, see this.
I've written a piece of code that loops a page list and adds some info of each page to a dataset. All works well so far but then I added a function to also add the url of the files located in the page folder of that each page and then it all started acting a bit weird. No matter what I wrote in the loop there was no result so I added a break point before calling the function (below) to see what happened. If I step through all I see is the steps going from the GetImages(); to the first line in the function (VirtualPathUnifiedProvider provider = ...) and then back to the GetImages();. No error thrown, no stepping through the lines before the call of GetImages(); but all the results from the lines before it are in the DataSet as expected.
Any idea what might be going on here? I'm really confused about this.