I think what you want is to use the BackgroundWorker:
var bw = new BackgroundWorker();
bw.DoWork += (sender1, eventArgs1) =>
{
var bw1 = (BackgroundWorker)sender1;
System.Threading.Thread.Sleep(1000);
bw1.ReportProgress(1);
};
bw.ProgressChanged += (sender2, eventArgs2) =>
{
richTextBox1.Text += "Now" + i + " is running \n";
};
bw.RunWorkerAsync()
I would use a Task with the Dispatcher in WPF, but the above will work with WinForms.
Forgot the start of the Background worker