Adding row to DataGridView from Thread
Posted
by she hates me
on Stack Overflow
See other posts from Stack Overflow
or by she hates me
Published on 2010-06-06T23:03:15Z
Indexed on
2010/06/06
23:12 UTC
Read the original article
Hit count: 398
Hello,
I would like to add rows to DataGridView from two seperate threads. I tried something with delegates and BeginInvoke but doesn't work.
Here is my row updater function which is called from another function in a thread.
public delegate void GRIDLOGDelegate(string ulke, string url, string ip = "");
private void GRIDLOG(string ulke, string url, string ip = "")
{
if (this.InvokeRequired)
{
// Pass the same function to BeginInvoke,
// but the call would come on the correct
// thread and InvokeRequired will be false.
object[] myArray = new object[3];
myArray[0] = ulke;
myArray[1] = url;
myArray[2] = ip;
this.BeginInvoke(new GRIDLOGDelegate(GRIDLOG),
new object[] { myArray });
return;
}
//Yeni bir satir daha olustur
string[] newRow = new string[] { ulke, url, ip };
dgLogGrid.Rows.Add(newRow);
}
© Stack Overflow or respective owner