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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:14:32+00:00 2026-05-13T09:14:32+00:00

I have a BitmapFrame object created by a working thread (not UI thread) and

  • 0

I have a BitmapFrame object created by a working thread (not UI thread) and placed in a static collection.

Then, I have a different working thread assigning this object to an Image object owned by the UI thread.

As you can imagine, I can’t access theImage object (As it belongs to the UI thread) and I get: "calling thread cannot access the object because different thread owns it".

So, I tried solving it by doing the following:

imageMainImage.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action<ImageItem>(delegate(ImageItem A) {
    imageMainImage.Source = A.ManipulatedPreview;                
}), II);

II is the Image item (created by a working thread and available through a static class) and imageMainImage is the Image object owned by the UI thread.

But now, again, I get the "calling thread..." but this time I get it because the II object belongs to a different thread (the first working thread).

What I’m trying to do is have one thread work with 2 Image elements that belong to different threads.

I’m trying to work the whole process differently but was wondering, is there a solution to this?

thanks.

  • 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-13T09:14:32+00:00Added an answer on May 13, 2026 at 9:14 am

    You need to do a CheckAccess() call on the Dispatcher first to see if you are on the UI thread and therefore capable of updating the UI item.

    Here is a helper function i wrote to update my comboboxes in WPF, you can easily adapt it to suit an Image control, and it is a good example of the CheckAccess call:

        private void UpdateComboDataSource<T>(ComboBox ctrl, IEnumerable<T> datasource, string displayPath, string valuePath)
        {
            if (ctrl == null)
                throw new ArgumentNullException("Control to be bound must not be null");
    
            //check if we are on the control's UI thread:
            if (ctrl.Dispatcher.CheckAccess())
            {
                //we have full access to the control, no threading issues, so let's rip it up and databind it
                datasource = datasource.OrderBy(x => x);
                if (displayPath != null && ctrl.DisplayMemberPath == null)
                    ctrl.DisplayMemberPath = displayPath;
                if (valuePath != null && ctrl.SelectedValuePath == null)
                    ctrl.SelectedValuePath = valuePath;
    
                ctrl.ItemsSource = datasource;
            }
            else
            {
                //we don't have full access to the control because we are running on a different thread, so 
                //we need to marshal a call to this function from the control's UI thread
                UpdateComboDataSourceDelegate<T> del = new UpdateComboDataSourceDelegate<T>(this.UpdateComboDataSource);
                ctrl.Dispatcher.BeginInvoke(del, ctrl, datasource, displayPath, valuePath);
            }
        }
    
    
    private delegate void UpdateComboDataSourceDelegate<T>(ComboBox ctrl, IEnumerable<T> dataSource, string displayPath, string valuePath);
    

    So the function checks if it has access, if it does it assigns the datasource. If it doesn’t, then it calls itself back but this time within the context of the UI thread.

    There is probably a more succinct way to code the delegate creation, but that isn’t so good for people trying to understand the sample, hence the explicit delegate definition.

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

Sidebar

Ask A Question

Stats

  • Questions 422k
  • Answers 422k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The mailing list has now been moved from codehaus to… May 15, 2026 at 11:23 am
  • Editorial Team
    Editorial Team added an answer I managed to accomplish my goal with the help of… May 15, 2026 at 11:23 am
  • Editorial Team
    Editorial Team added an answer Maybe you can try something like this : <form method="post"… May 15, 2026 at 11:23 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.