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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:46:57+00:00 2026-05-13T12:46:57+00:00

I am a beginner with WPF and trying a home project to become familiar

  • 0

I am a beginner with WPF and trying a home project to become familiar with the technology. I have a simple form where the user selects an image file, I then display EXIF data along with a thumbnail of the image. This is working fine but when I select a RAW image file (~9 MB) there can be a slight delay while the thumb loads, so I thought I could use the BackgroundWorker to decode the image and the user can view the EXIF data, then when the image has been decoded it is displayed.

The BitmapSource object is declared in the BackgroundWorkers DoWork method:

worker.DoWork += delegate(object s, DoWorkEventArgs args)
{
    string filePath = args.Argument as string;

    BitmapDecoder bmpDecoder = BitmapDecoder.Create(new Uri(filePath), BitmapCreateOptions.None, BitmapCacheOption.None);
    BitmapSource bmpSource = bmpDecoder.Frames[0];
    bmpSource.Freeze(); //As suggested by Paul Betts

    args.Result = bmpSource;
};

the problem that I’m running into is when I try to set the source of my Image control in the RunWorkerCompleted method I receive an error because the object is owned by another thread.

worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
    imgThumb.Source = args.Result as BitmapSource;
};

I tried using the imgThumb.Dispatcher.BeginInvoke() method to set the source but this didn’t work either, I guess it’s because it’s the args.Result that is owned by another thread, and not the imgThumb? How can I get round this?

It could be that I was coding my Dispatcher wrong (the following is from memory, I deleted what I had).

imgThumb.Dispatcher.Invoke(new Action<BitmapSource>(
    delegate(BitmapSource src)
    {
        imgThumb.Source = src;
    }
), bmpSource);

Any suggestions or ideas are welcome.

Update

Changed my DoWork method to use BitmapCreateOptions.None rather than .DelayCreation but now I get the following error when loading RAW files (Canon .CR2 files is all I have tested to date), the code works fine for jpg’s. Could this be an issue with the Canon Codec I installed to allow me to display the RAW files?

The application called an interface
that was marshalled for a different
thread. (Exception from HRESULT:
0x8001010E (RPC_E_WRONG_THREAD))

  • 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-13T12:46:57+00:00Added an answer on May 13, 2026 at 12:46 pm

    Call Freeze() on the BitmapSource and you won’t have this problem (Freezing gets rid of the threading restrictions, but makes the object immutable)

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

Sidebar

Related Questions

I'm a beginner in WPF and have to add functionality to someone's user interface.
Beginner to assembly programming for x86. I have a simple asm file which I
I am a beginner to WPF . I have a data grid for showing
Beginner in Android development. My code crashes. I have made a simple Java method
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
I'm a C# beginner and am trying to implement a numeric pad in WPF.
I am beginner on WPF and need your help. Problem: I have 4 buttons
I'm a complete beginner in WPF and have an app that uses StoryBoard to
I have a datagrid in a WPF populated from a csv file. This is
I am trying to implement a WPF MVVM application. And I am a beginner

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.