Hello,
Your question is a bit unclear, so it is difficult to give an definite answer.
If it helps this is an example of how you could use a background worker:
BackgroundWorker backgroundWorker;
public Form1()
{
InitializeComponent();
backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.WorkerSupportsCancellation = true;
}
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (true)
{
Console.WriteLine(DateTime.Now.ToLongTimeString());
Application.DoEvents();
}
}
private void button1_Click(object sender, EventArgs e)
{
backgroundWorker.RunWorkerAsync();
}
private void button2_Click(object sender, EventArgs e)
{
backgroundWorker.CancelAsync();
}
Obviously there are other ways to do it.
Hope it helps,
Valery.