Hello Dear
Some times a go i was working on a chat program . because a lot of client connect to server , it was necessary that server work on multiple thread , i had a lot of problem like you , bu finally i could solve my problem . there is a standard way to communicate between thread and controls in each thread , and it is 'Invoke' method which is one of methods of 'Control' class.
I guild you by one example :
I create a project with two forms : Form1 , Form2
Form1 has two button : BtnOpenForm , BtnCloseForm
when user clicks BtnOpenForm a new thread creates and in that thread create a new instance of Form2 then this new insatnce is shown
when user clicks BtnCloseForm this new instance will close
this is an abstract Sample not a complete one . but you can Communicate between any controls in any thread
Form1 :
public delegate void DelegetCloseForm();
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Form2 F;
private void BtnOpenForm_Click(object sender, EventArgs e)
{
System.Threading.Thread T = new System.Threading.Thread(delegate()
{
F = new Form2();
F.ShowDialog();
});
T.Start();
}
private void BtnCloseForm_Click(object sender, EventArgs e)
{
this.F.Invoke(F.Dlg);
}
}
Form2 :
public DelegetCloseForm Dlg;
private void CloseForm()
{
this.Close();
}
public Form2()
{
InitializeComponent();
Dlg = new DelegetCloseForm(this.CloseForm);
}
this is very simple , just need a little practice
if had problem comment me
Good luck