Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run BackgroundWorker after another one completed

I want to start a BackgroundWorker after another one is completed. I'm not sure on how to write the code for it, so I don't really have anything to show.

I thought about writing it in the RunWorkerCompleted, but that seems like the wrong place to put logic for starting another worker.

Where and how should I do this?

Basically, I want to use the same worker, but to do something else. Like in step 1 it parses data from files and in step 2, after step 1 is completed, it should write the parsed data from memory to the database.

like image 516
F.P Avatar asked Jan 02 '12 16:01

F.P


1 Answers

You can instead use the .NET 4.0 Task class and then queue more work using Task.ContinueWith.

like image 197
Tudor Avatar answered Sep 29 '22 01:09

Tudor