I have the following code:
List<string> list = SomeFunction();
this.myComboBox.DataSource = list;
For some reason, the assignment to DataSource is taking a surprising amount of time (about 1.4 seconds), when the list only contains 4 items.
Any idea why this is?
Edit:
SomeFunction()
looks in several folders on disk for the existence of a particular .xml file, and if it exists, puts the containing folder name into the list which it returns.
Investigation:
I stuck a call to DateTime.Now around the DataSource assignment, and it comes back at ~1400ms each time. This leads me to believe that it is purely the DataSource assignment that causes it. However, I created a dummy List; Add()
ing strings directly to it. This datasource executes in ~200ms. So perhaps it is not the DataSource assignment after all, and has something to do with SomeFunction
. However, then I tried just inserting the strings one by one, and it executes in ~0ms.