I Will Run This Ping App UI Not Working And Not Respond
Here Is Code
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Net.NetworkInformation;
- using System.Threading;
- namespace WindowsFormsApp1
- {
- public partial class Form1 : Form
- {
- public static int check = 0;
- static System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- ping();
- }
- public void ping()
- {
- int q = Convert.ToInt32(packet1.Text);
- check = 1;
- int milliseconds = 500;
- byte[] packet = new byte[q];
- Ping myPing = new Ping();
- PingReply reply;
- while (true)
- {
- Thread.Sleep(milliseconds);
- reply = myPing.Send(ping1.Text, milliseconds, packet);
- if (reply.Status == IPStatus.Success)
- {
- result1.AppendText("Reply from = " + reply.Address + " Bytes = " + reply.Buffer.LongLength + " Time = " + reply.RoundtripTime + " TTL = " + reply.Options.Ttl);
- result1.AppendText(Environment.NewLine);
- }
- else
- {
- result1.AppendText(reply.Status.ToString());
- result1.AppendText(Environment.NewLine);
- }
- }
- }