Add items to a list box from a seperate thread
Posted on 2013-05-14
I figured this would be easier than it is working out to so it has to be a case that I' just can't see the trees for the forest.
On form1 I have a picture box shows an animated gif and has a listbox that I need to populate with a list of Sql Servers.
I can retrieve the list of servers without any problem except while the process is running the picture box stops and I understand why. So I created a BackgroundWorker to handle the routine that checks for the server by using the DoWork event. That runs fine goes through and finds the servers that it is supposed and my picture boxes are doing what they are supposed to do. Just for clarity this routine is in a completely separate module.
My question is how do I add items to my listbox from the routine that is called in the second thread that generates the list of servers. I have tried several different ways and I get all kinds of exception and delegate errors.