i have a problem with Winforms app with 2 threads: in a second thread I pull messages from WCF service. When there are messages I need to update the GUI : I do this in accordance with patten found here How to update the GUI from another thread in C#? . Here is the code:
private delegate void CWU(int ID);
public void AddNewTab(int id)
{
if (this.tabControl1.InvokeRequired)
{
CWU cb = new CWU(AddNewTab);
this.tabControl1.Invoke(cb,id);
}
else
{
User ToChatWith = ContactsHelper.AllFriends.Find(e => e.ID == id);
tabpage.Text = ToChatWith.ToString();
this.tabControl1.TabPages.Add(tabpage);
this.tabControl1.SelectTab(tabpage);
}
tab is added properly and when we leave this method the app is not responding, no info in debug. When I run my app after adding this tab i get AppHangB1 without any details. Can you help me?