MultiThread in C#
Hello everybody. I have a question. I'm using C# on Microsoft Visual Studio 2005. I have a function (Search). An a cmd_SingleThread button has code { Search(); } When I click, everything is OK but I have second button, called MultiThread button has code { Thread th=new Thread(ThreadStart(Search)); th.Start(); } When I click this button, it always inform a Exception called InvalidOperationException. "Cross-thread operation not valid: Control 'listBox1' accessed from a thread other than the thread it was created on." Can you explain? Thank you

abdus salamPosted May 23, 2007, 4:01 AM
I used this control in one of my projects for Import CSV utility. I had to import users from CSV file into database. Beside this basic functionality, there was a requirement to show a progress bar and some label controls to show the progress of import on parent form. So I created one form (Main thread) and used the BackgroundWorkerThread control (secondary thread) to execute the import code and update the UI controls on Main form. You can drag this control from the toolbox under the component tab on the required form
I hope you will like the idea.