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

  • Home
  • SEARCH
  • 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 6138793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:54:36+00:00 2026-05-23T17:54:36+00:00

What happens to the data that is passed to and from a background worker?

  • 0

What happens to the data that is passed to and from a background worker?

Data is passed from the main thread to the background worker using RunWorkerAsync:

backgroundWorker.RunWorkerAsync(myData);

This is received in the DoWork event handler in the background thread:

myData = (Data)e.Argument;

After DoWork has processed the data, it returns it using e.Result:

e.Result = myData;

This is received in the RunWorkerCompleted event handler in the main thread:

myData = (Data)e.Result;

BackgroundWorker is taking care of passing the data between the threads. I am expecting to pass large amounts of data to and from a background worker so I want to know what the overhead of this transfer is, and if there is a better way of processing a large amount of in-memory objects in a background worker. I would also like to know it is possible to access the data in the background worker from the main thread in a thread-safe manner.

For reference, I am using C#, .Net 3.5 and Windows Forms.

  • 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-23T17:54:37+00:00Added an answer on May 23, 2026 at 5:54 pm

    There really is no overhead (provided Data is a class), since only the reference is passed around. The data itself isn’t “copied” into a thread – all threads can access the data in the process (for the most part).

    I would also like to know it is possible to access the data in the background worker from the main thread in a thread-safe manner.

    Yes, it’s possible to access the data, but in order to do it in a thread-safe manner, you’ll need to manage the synchronization yourself. This typically requires something like a lock, though there are many options depending on what you are trying to accomplish.

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

Sidebar

Related Questions

It often happens to me to handle data that can be either an array
I'm using hibernate 3 with c3p0 for a program which constantly extracts data from
I am calling startActivity to pass data from one activity to another using an
I am guessing that even reading from shared data in openmp causes some parallel
I'm having trouble returning data from my controller using an ajax post function. What
This happens repeatedly and is very annoying. I upload some PHP code to a
I have a mixed client-side/server-side validation using jQuery validation plugin. The validation happens on
i am creating an app that needs a database. i created it using sqlite
I need advice on how to return a limited set of data from an
I got an email today saying: In every case that we have examined, this

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.