title: How to start thread if button pressed and stop it if pressed again?
body: <p>I'm using the next code to do what I'm asking for :</p>
  
  <pre><code>private delegate void CallerDelegate(object e);
  CallerDelegate caler = new CallerDelegate(MethodToCall);
  </code></pre>
  
  <p>on button click event :</p>
  
  <pre><code>if (currBusyThrd != null &amp;&amp; currBusyThrd.IsAlive)
     {
      currBusyThrd.Abort();
     }
  ThreadPool.SetMaxThreads(1, 1);
  //queue the work for thread processing
  ThreadPool.QueueUserWorkItem(new WaitCallback(WaitCallbackMethod))
  </code></pre>
  
  <p>"WaitCallbackMethod" Method is :</p>
  
  <pre><code>void WaitCallbackMethod(object stateInfo)
    {
       // argList : i put some argument in a list to use it in "MethodToCall" ...
       BeginInvoke(caler,argList);
    }
  </code></pre>
  
  <p>and the method i'm calling by the thread is :</p>
  
  <pre><code>void MethodToCall(object args)
   {
   //Here I get the thread I'm calling to stop it when btn clicked again
   currBusyThrd = Thread.CurrentThread;
  
   // The rest of the code ...
   }
  </code></pre>
  
  <p>I feel that this is wrong ...
  How to do it right ?</p>
  
  <p>Actually the calling will be by TextBox_KeyUp .. so every time the user enter a char the code will execute again .. and the BackgroundWorker didn't work .</p>