From your description, it seems that the steps are connected and sequential, so I would implement them as a single BGW, where DoWork performs both steps with a ReportProgress call between the parsing step and the writing step to the database.
You can then handle the ProgressChanged event, which is executed in the user interface thread, to execute any logic after the parsing stage is complete, knowing that the worker is already writing to the database.
ReportProgress takes an integer to determine the percentage of completion of the background task and an optional user object. Therefore, in your ProgressChanged handler, you need to have logic to interpret this progress information. In this case, as a two-step job, you can just call ReportProgress(50) .
source share