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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:20:43+00:00 2026-05-17T20:20:43+00:00

This may be seen as a duplicate of Thread safety, lists, binding and WPF

  • 0

This may be seen as a duplicate of Thread safety, lists, binding and WPF, but I post it anyway since I’m not fully happy with the accepted response, and I might be able to express what I suspect is the same question more exactly.

Any operations related to UI in WPF/Silverlight must be performed on the UI, including INotifyPropertyChanged and INotifyCollectionChanged, but – when data binding to an object (single object or collection), will the framework only read the values of the data bound object synchronously in the event handler, or could it come back any time and query the object?

What I want to do is have a worker thread updating a data bound object (often), periodically raising a CollectionChanged event if the collection is dirty to trigger a UI update. If I can know that the framework will only read the values in the collection in the event handler, a simple lock in the code raising the event to lock the collection would be enough, but if not, I will have to perform a deep copy of the collection.

So 1) can the framework read my collection even outside of the event handler and 2) if it can, is there a better way of updating something on a worker thread and publish it to the UI other than performing a deep copy?

  • 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-17T20:20:44+00:00Added an answer on May 17, 2026 at 8:20 pm

    You can´t guarantee that something will only read your structure in the event handler since the databinding could be refreshed if any other window controls causes a refresh on the hiearchy so locking the structure isn’t what I would do.

    As mentioned in the post you´ve found the way to do this is to make sure that the event is posted to the GUI-thread in a safe manner using the dispatcher like below:

    public void DoWork(object sender, DoWorkEventArgs e)
    {
        // Update GUI
        Dispatcher.BeginInvoke(new Action(MyPostMethod), DispatcherPriority.Normal);
    }
    
    public void MyPostMethod()
    {
        // Here you´d post whatever data to the gui
    }
    

    I usually use the Action and Action<T> constructs to not having to create new delegates for every to-gui posting.

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

Sidebar

Related Questions

I know you may regard this post as another duplicate, while it's not. It's
This may be duplicate question but I could not find one on SO. If
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
this may sound pretty straight forward, but still I want to post this question
This may be kind of a simple question, but I haven't seen a direct
This may be a completely dumb question, but I've seen a couple examples declaring
This question may be seen as subjective, but I'd like to ask SO users
This may be a question that others have seen, but I am trying to
This may be a stupid question, but here goes. I've seen several projects using
This may be a dumb question but i'll give it a go anyway. 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.