예제 #1
0
파일: Form1.cs 프로젝트: jmark9706/Pinger
 private void button2_Click(object sender, System.EventArgs e)
 {        /// start second pinging thread
     {
         string    server  = textBox1.Text;
         ushort    id      = 1;
         ushort    seq     = 1;
         IPAddress address = null;
         seqno        += 1;
         textBox2.Text = "Resolving address";
         this.Invalidate();
         this.Update();
         p       = new PingSite();
         pthread = new Thread(new ThreadStart(p.ThreadProc));
         int rc = p.ResolveHost(server, ref address);
         p.taddress = address;
         p.tseqno   = 0;
         p.go       = true;
         p.bptr     = this;
         p.q        = q;
         p.mythread = pthread;
         if (rc == 0)
         {                             // start the thread
             a.start           = true; // start the analysis thread
             textBox1.ReadOnly = true;
             button2.Enabled   = false;
             button3.Enabled   = true;
             textBox2.Text     = "Pinging";
             this.Invalidate();
             this.Update();
             pthread_started = true;
             pthread.Start();
         }
         else
         {
             pthread       = null;
             textBox2.Text = "Unable to resolve hostname";
         }
     }
 }
예제 #2
0
파일: Form1.cs 프로젝트: jmark9706/Pinger
        private void button1_Click(object sender, System.EventArgs e)
        {         // single ping
            TimeSpan  elapsed = new TimeSpan(0);
            string    server  = textBox1.Text;
            ushort    id      = 1;
            ushort    seq     = 1;
            IPAddress address = null;

            seqno        += 1;
            textBox2.Text = "Resolving address";
            this.Invalidate();
            this.Update();
            PingSite p  = new PingSite();
            Thread   t  = new Thread(new ThreadStart(p.ThreadProc));
            int      rc = p.ResolveHost(server, ref address);

            if (rc == 0)
            {
                textBox2.Text = "Pinging";
                this.Invalidate();
                this.Update();
                Sample smp = new Sample();
                rc = p.OnePing(address, 5, id, seqno, ref elapsed, ref smp);
                if (rc == 0)
                {
                    textBox2.Text = "OK " + seqno.ToString();
                    textBox5.Text = elapsed.Milliseconds.ToString();
                }
                else
                {
                    textBox2.Text = "No response";
                }
            }
            else
            {
                textBox2.Text = "Unable to resolve hostname";
            }
        }