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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:32:30+00:00 2026-06-09T01:32:30+00:00

A rather simple question (I think), but I don’t seem to see an answer

  • 0

A rather simple question (I think), but I don’t seem to see an answer already. I know that some values are passed via value (like int and long), and others are passed by reference (like Strings) when you pass them to functions.

In my program, I have it using background worker so that the GUI doesn’t lock up when we are doing a long process in the background. I need to pass data back to the UI thread from another file, so I have been using events for that. Now I need to send a list of arrays of Strings back to the GUI thread to handle there, and I am worried how it will be handled. Basically, in the worker thread, I have a loop that will fill up the list, send it back to the GUI via an event handler, and then clear it so it can fill it up on the next pass through the loop and start again.

I am worried that when I do this, if the list is passed by reference, then on the UI thread, I would think that it would be cleared mid-read since the worker thread will still be clearing it in the background. Passing by would be far preferable in this case, and I can find ways to force it(copy to some holder array or add a mutex or something of the sort), but I thought it would be good to know if event arguments are passed via reference or value in general, or is it just the same as methods, and it will pass them as arguments are normally passed?

  • 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-09T01:32:32+00:00Added an answer on June 9, 2026 at 1:32 am

    I know that some values are passed via value (like int and long), and others are passed by reference (like Strings) when you pass them to functions.

    Nope. By default everything is passed by value – but when you’re using reference types, the “everything” is a reference. That reference is passed by value. That’s not the same as pass by reference. See my article on parameter passing for more details.

    Event arguments are exactly the same – any references are passed by value, assuming the corresponding delegate doesn’t use out or ref parameters.

    EDIT: So to address your concern: yes, if your event argument is mutable and you’re going to act on a different thread, you should create a copy first… or alternatively, pass the existing reference and then create a new (empty) list in your worker thread.

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

Sidebar

Related Questions

I think that's a rather simple Question but I don't get it the way
I think its a rather simple question but I couldn't really find an answer
I have a rather simple question that I could normally debug myself, but I
I know is a rather simple question but I just can't find an appropriate
I have rather simple, I imagine, question about CRTP , but I cannot seem
Rather a simple question. But the implications are vast. Over the last few weeks
my question is rather simple, if you have an pure virtual class (interface) but
This is a rather simple question, and I think it breaks down to whether
I think this has to be a very simple question but I am not
Have a rather simple question. Does anyone knows if i can use jparallax both

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.