Can you have more than one backgroundworker run at one time

williamsje@welchpkg.com 21 Reputation points
2021-09-01T16:07:39.863+00:00

I just recently found this object called backgroundworker. I am using it to do large imports while keeping the user updated on the process via the UI. I have several programs that need to do more than one large import and I would like to run them at the same time. When I try to use more than 1 background worker at the same time, when the first one gets done the second one stops working. Is there away to have more than 1 background worker run at the same time and have both complete when they are done with each of their tasks?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,091 questions
{count} votes

Accepted answer
  1. Karen Payne MVP 35,451 Reputation points
    2021-09-01T17:30:23.437+00:00

    Your best option is to not use the BackGroundWorker but instead use Task-based asynchronous programming where multiple operations can run at the same time.

    Task based operations can be setup for cancellation, work with events and Interface such as IProgress (see also Reporting Progress from Async Tasks).

    Bottom line is task base programming asynchronously you have more control than with a BackGroundWorker component.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.