I have this function in the main form:
public void Check()
{
UpBox myClass = new UpBox();
myClass.UpdateBox(listBox1,"Hello");
}
public void Initial()
{
Thread thread = new Thread(new ThreadStart(Check));
thread.Start();
}
class UpBox
{
private delegate void Box(ListBox list, string text);
public void Box2(ListBox list,string text)
{
list.Items.Add(text);
}
public void UpdateBox(ListBox list, string text)
{
this.Invoke(new Box(Box2),list,text);
}
}
Now, as I'm inside a thread, I'd have to use Invoke method to insert items in a ListBox.Invoke doesnt work.
Anyone can give me a hand here?
This Class is in a separated *.cs file.
Thx.