How to pass ArrayList object back from a Thread
-
I've written multithreaded code using MFC and understand that well. I'm working on a C# code in which I want to fill in an ArrayList with some data, using a separate thread, and then use the ArrayList data to populate a ListBox on my Form. Can someone point me to a good example of how to pass data back from a thread in C#? I've found some examples using BackgroundWorker ..., but I'm not sure if that is the only way, or the best way, etc. None of my C# books have anything but very simple threading examples. Thanks,
Tom
-
I've written multithreaded code using MFC and understand that well. I'm working on a C# code in which I want to fill in an ArrayList with some data, using a separate thread, and then use the ArrayList data to populate a ListBox on my Form. Can someone point me to a good example of how to pass data back from a thread in C#? I've found some examples using BackgroundWorker ..., but I'm not sure if that is the only way, or the best way, etc. None of my C# books have anything but very simple threading examples. Thanks,
Tom
This article[^] will tell you how your thread can access the GUI parts. And yes a BackgroundWorker often is the best way to achieve this. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.