I have a basic foreach
loop that calls a static method which makes a connection to a database and inserts some data. For some reason it will only iterate through the first item in the collection when I run the application without debugging. If I debug the application and set a break point on the foreach
loop, it will iterate through all of the items in the collection.
If I set a break point and step over the foreach
loop, it will demonstarte the same behavior as if I was running the application without debugging.
Does anyone know what would cause this type of behavior?
Here is a simplified version of the source code:
List<MyObject> objectlist = new List<MyObject>();
//some code to populate list
foreach(MyObject myobject in objectlist)
{
string a = "a";
string b = "b";
MyLibrary.UpdateDatabase(a, b);
}
(I am using Visual Studio 2008 SP1)
Update
The process does not throw any exceptions with or without debugging the application.