I have created a simple form home
and there is another file Mouse_Tracking.cs
.
Mouse_Tracking.cs
class is a thread class. I want to start and stop that thread using two different button click in home
form.
How can I do this ?
Main form:
namespace computers
{
public partial class home : Form
{
public home()
{
InitializeComponent();
}
private void btn_start_Click(object sender, EventArgs e)
{
var mst = new Mouse_Tracking();
Thread thread1 = new Thread(new ThreadStart(mst.run));
thread1.Start();
}
private void btn_stop_Click(object sender, EventArgs e)
{
//Here I want to stop "thread1"
}
}
}
Computers
class:
namespace computers
{
public class Mouse_Tracking
{
public void run()
{
// Some method goes here
}
}