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 6146361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:56:09+00:00 2026-05-23T18:56:09+00:00

I am using a BackgroundWorker a bit differently than I was used to. Usually,

  • 0

I am using a BackgroundWorker a bit differently than I was used to.

Usually, I use the BW to update some graphical control, and I perform all the required task in the DoWork method, return the result and do the assignments to the RunWorkerCompleted event handler.

Here, I just wanted to assign the result of some computation (DB query) to some private variable _myList of the current Window.

I was very suprised to see that I was allowed to assign the list from the DoWork method, and I was really surprised.

I just wanted to know if it was normal or if it was not recommended for some reason?

  • 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-23T18:56:09+00:00Added an answer on May 23, 2026 at 6:56 pm

    You will be allowed to assign to the variable as it doesn’t have any checks guarding against cross-thread actions, the only things that do these checks are the UI elements.

    As for if it is recommended, you are stepping into the realms of multi-threaded synchronisation.

    Usually you lock access to a resource before attempting to use it, to guard against things like race conditions:

    static object Locker = new object();
    
    lock (Locker)
    {
       // variable assignment in here.
    }
    

    If your usage is basic, as in, you set into it then at the end of the background worker chunk you read from it, then you will be safe to do this. However, if other stuff attempts to write to it, or you have code that checks variable content before acting on it, then you start to get race conditions.

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

Sidebar

Related Questions

A winforms dialog is using BackgroundWorker to perform some asynchronous operations with significant success.
I'm using BackgroundWorker for the first time, and use is not entirely clear. Can
Say I'm showing the user a form, and using a BackgroundWorker to do some
What is the difference between: Starting a new thread Using TPL Using BackgroundWorker All
I was using a BackgroundWorker to download some web sites by calling WebClient.DownloadString inside
Learning to build multithreading WPF applications I read about some restrictions in using BackgroundWorker
I am using the BackgroundWorker to do some heavy stuff in the background so
I'm having some problems using a backgroundworker in a WPF app. Here's the situation:
All, I have used the Thread and BackgroundWorker classes with success to facilitate a
I've got a bit of a problem, I'm using a backgroundworker to do a

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.