title: A While Loop Thread
body: <p>So I've been trying to create a bit of code that sends data on a while loop, specifically an alive packet to a server through a UdpClient.</p>
  
  <pre><code> static void doSend(string ip, int port)
      {
          while (isSending)
          {
              _sockMain = new UdpClient(ip, port);
              // Code for datagram here, took it out
              _sockMain.Send(arr_bData, arr_bData.Length);
          }
      }
  </code></pre>
  
  <p>But when I call the "Stop" method, it gets stuck in a constant loop and doesn't come out. How can I put the while loop into a Thread? So I can abort the thread on stop, cancelling the loop?</p>