buttonClick()
{
StartStop = false;
Thread myThread=new Thread(myThreadFunc);
myThread.Start();
}
myThreadFunk()
{
while(!StartStop)
{
//Code
Thread.Sleep(500);
}
}