I have a base loop foreachthat calls a static method that makes a database connection and inserts some data. For some reason, it will only iterate over the first element of the collection when the application starts without debugging. If I debug the application and set a breakpoint in the loop foreach, it will iterate over all the elements in the collection.
If I set a breakpoint and step over the loop foreach, this will exhibit the same behavior as when starting the application without debugging.
Does anyone know what can cause this type of behavior?
Here is a simplified version of the source code:
List<MyObject> objectlist = new List<MyObject>();
foreach(MyObject myobject in objectlist)
{
string a = "a";
string b = "b";
MyLibrary.UpdateDatabase(a, b);
}
(I am using Visual Studio 2008 SP1)
Update
.