Download Ping Example Code (10kb)
The following is a simple code to invoke a delegate with parameter. I created this to update label control on the form asynchronously. I did not quite work I was hoping for but the code does pass parameter to the delegate
private void Ping_Click(object sender, EventArgs e) { BeginInvoke(new InvokeDelegate(UpdateLabelAsych),"test"); Ping ping = new Ping(); PingReply pingresult = ping.Send(txtIpAddress.Text); if (pingresult.Status.ToString() == "Success") { //Response.Redirect("http://xxx.xxx.xxx.xx/sample"); BeginInvoke(new InvokeDelegate(UpdateLabelAsych), "Success"); } else BeginInvoke(new InvokeDelegate(UpdateLabelAsych), "Failure"); } private void UpdateLabelAsych(string msg) { label1.Text = msg; } private delegate void InvokeDelegate(string s);
Pingback: Software Development Blog » favicon not showing