I am making a C# program which is runnning 2 threads. The main UI thread, and a seperate network thread i make myself.
I have figured out, that if i need to change something in the UI from the network thread, i will need to call a deligate method, which works just fine:
// Declared as a global variable
public delegate void ListBoxFirst();
//Then call this from the network thread
listBox1.BeginInvoke(new ListBoxFirst(InitListBox));
//Which points to this
public void InitListBox() {
listBox1.SelectedIndex = 0;
}
Now i need to be able to read a UI value (a listbox.selectedindex) from the network thread, but it shows the error "cannot implicitly convert type 'system.iasyncresult' to 'int'" if i try it the same way (of course with "int" instead of "void", and a "int a = " before the listbox1.begininvoke). I have googled a lot but im pretty new to C# so i get really lost.
Any help would be much appriciated