I have a simple Backgroundworker and want to write my result to the Console and I also want to report the process.
class Program
{
private static BackgroundWorker worker;
static int counter;
static void Main(string[] args)
{
worker = new BackgroundWorker();
worker.WorkerReportsProgress = true;
worker.RunWorkerAsync();
Console.ReadLine();
}
static void worker_DoWork(object sender, DoWorkEventArgs e)
{
while (true)
{
counter++;
worker.ReportProgress(counter);
}
}
static void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
Console.WriteLine(counter);
}
static void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
}
}
But how can I give my String (or more then 1 String) to my ReportProcess Function?