I have a class that updates a ListBox in the program window. Since it is running in its own thread, it is not allowed to do that directly. What is the best way for a thread to invoke a method call to another thread using C# Code sample will be appreciated.

Re: Visual C# General Inter-thread communication


As the background thread makes progress it can call ListBox1.Invoke(...) to run code on the UI thread to put the results in the list box.

Another way to do this is to use BackgroundWorker and report the data to be added to the ListBox as the "user state" when you make calls to ReportProgress. See for examples.