I have an application that pings every IP in the datagridview in order to compile a list of responsive IP RoundtripTime.When finished the step,I will push the RoundtripTime back
this
refers to the current instance. A static method is not against an instance and instead just the type. So there is no this
available.
So you need to remove the static
keyword from the event handler declaration. Then the method will be against the instance.
You may also need to marshal the code back to the UI thread before trying to update the data grid view - if so then you'd need code something like the following:
delegate void UpdateGridThreadHandler(Reply reply);
private void ping_PingCompleted(object sender, PingCompletedEventArgs e)
{
UpdateGridWithReply(e.Reply);
}
private void UpdateGridWithReply(Reply reply)
{
if (dataGridView1.InvokeRequired)
{
UpdateGridThreadHandler handler = UpdateGridWithReply;
dataGridView1.BeginInvoke(handler, table);
}
else
{
DataGridViewRow row = this.current_row;
DataGridViewCell speed_cell = row.Cells["speed"];
speed_cell.Value = reply.RoundtripTime;
}
}