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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:50:37+00:00 2026-06-13T06:50:37+00:00

Say I have an object whose members I’d like to use in two separate

  • 0

Say I have an object whose members I’d like to use in two separate tasks. What would be the best approach? Since a struct passes by value should I change the object to a struct and then create two separate copies of the object, and pass that to the two tasks? Also since the object’s properties are coming from a database I suppose I could create instances inside of each task.

Which approach would be the most efficient?

  • 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-06-13T06:50:38+00:00Added an answer on June 13, 2026 at 6:50 am

    As hinted by Henk in the comments on the OP…

    If the object’s properties are being used solely for reference, there’s no problem with instantiating the object once and passing it in to multiple tasks, however, if the tasks are going to be changing properties on the object, you need to deal with all the usual multi-threading issues.

    In addition, since you mention that these objects represent Db records, I’d guess you’re getting them from an ORM. If you’re using the Entity Framework, the proxy classes it creates are definitely not thread-safe when changing properties.

    So really, it depends on your usage I’d be tempted to do it all inside each task so the task is a stand-alone unit and later changes to the work it does by a developer unaware of this limitation won’t result in unexpected race conditions. (Assuming your’re not dealing with a large number of entities and memory usage is not a concern)

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

Sidebar

Related Questions

Lets say that you have a business object whose current state implies that there
Say I have an object-like data record like this: $article = array( 'title' =>
Lets say I have an object with two boolean properties: public bool AdvancedMode{ get;
Let's say I have a Border whose DataContext is an object of type MyViewModel.
I have an object, say a note, whose parameters I want to save in
Say I have a business. If I want to turn an object whose class
(using vb.Net 4.0) Say you have an object whose graph is fairly complex -
Lets say I have a object whose purpose is to hold a bunch of
Say I have an object containing a value. I wish to get the index
Say I have an object: struct Foo { int bar_; Foo(int bar) bar_(bar) {}

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.