可能重複創建線程其他:
Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.跨線程操作無效:從訪問控制「listBox1中」>線程比它是在
雖然我試圖將項目添加到列表框我在C#上收到以下錯誤。
跨線程操作無效:控制'listBox1'從 線程訪問,而不是創建線程。
的代碼:
private void Form1_Load(object sender, EventArgs e)
{
Jid jd = new Jid("USERNAME");
xmpp.Open(jd.User, "PASSWORD");
xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
agsXMPP.XmppConnection p;
xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence);
}
void xmpp_OnPresence(object sender, Presence pres)
{
listBox1.Items.Add(pres.From .User); --- **HERE I AM GETTING ERROR.**
}
我在C#有點新的,也有穿的,我用Google搜索和檢查過很多文章,包括SOF,但我仍然硝基甲苯知道漢王要解決的問題, 請幫幫我 。 謝謝。
這個頁面有幾十個關於同一主題的問題。我只是選了一個。 –