title: Convert Ping application to multithreaded version to increase speed - C#
body: <p>I have an application that pings every possible IP on your local subnet in order to compile a list of responsive IP addresses.  Currently it pings all 255 one at a time.  Is it possible to convert this app to use multiple threads to increase the speed by pinging more than one at a time?  I am new to the concept of multiple threads and figure this would be a good way to learn(as long as it's possible of course).</p>
  
  <p>also, any stylistic improvements you can educate me on would also be helpful.</p>
  
  <p>thanks ahead of time</p>
  
  <p>Here is the current pinging method in a backgroundWorker1_DoWork event.</p>
  
  <pre><code>        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
      {
              count = 0;
              for (int i = 1; i &lt; 255; i++)
              {
                  Ping ping = new Ping();
                  PingReply pingreply = ping.Send(IPAddress.Parse(locip[0] + "." + locip[1] + "." + locip[2] + "." + i));
                  count += 1;
  
                  if (pingreply.Status == IPStatus.Success)
                  {
                      status = "o";
                      repAddress = pingreply.Address.ToString(); ;
                      repRoundtrip = pingreply.RoundtripTime.ToString();
                      repTTL = pingreply.Options.Ttl.ToString();
                      repBuffer = pingreply.Buffer.Length.ToString();
                      string[] lineBuffer = { status, repAddress, repRoundtrip, repTTL, repBuffer };
                      ipList.Rows.Add(lineBuffer);
  
                  }
                      progressBar.Invoke(new MethodInvoker(UpdateProgressBarByOne));
                      progressStatus.Text = ("Pinging IP " + count + " of 254");
  
              }
              button1.Enabled = true;
              progressBar.Invoke(new MethodInvoker(ResetProgressBar));
  
      }
  </code></pre>