Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1099499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:44:42+00:00 2026-05-17T00:44:42+00:00

In a Winform application,I want to use a single backgroundworker (or may be one

  • 0

In a Winform application,I want to use a single backgroundworker (or may be one for each form) to do different tasks on different events. For eg: Search, Loading Data in grid, opening new forms, sending emails, File transfer etc.

How can i manage all this in backgroundWorker_DoWork() and backgroundWorker_RunWorkerCompleted() events?

What is the optimum way/ best practice to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:44:42+00:00Added an answer on May 17, 2026 at 12:44 am

    Usually, I end up caling the worker with a parameter, like this:

    backgroundWorker.RunWorkerAsync(<some argument here>);
    

    Then inside your DoWork method, you can retrieve the argument from e.Argument, and according to what the argument is, you know what you want to do with it.

    If you don’t need the argument for anything else, you can make an enum with the values you need, like Search, Load and so forth and pass that in, and then check that value inside DoWork to choose what you want to do. Remember that you have to cast back to the enum inside Dowork since e.Argument is an object.

    Regarding RunWorkerCompleted, you can populate e.Result with a value inside DoWork, and retrieve it inside the RunWorkerCompleted method as well.

    This is the best way of doing it, and will be thread safe all the way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use Entity Framework(with Self Track Entities) in my winform application; but
I want to create a WinForm application that must draw data coming from a
I want my WinForms application to create an instance of itself for each screen
I have a WinForms application, with login form, and I want to store the
I want to report status of an operation in a WinForm application written in
I am working on a C# WinForm application. I want to trigger some processing
I'm developing a winform application. I want to take input from user (i.e. the
I have a problem with MouseEvents on my WinForm C# application. I want to
I am creating desktop application in winform that will use Sqlite Database. So I
As I am working on windows .Net Windows form application, I want to know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.