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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:41:25+00:00 2026-06-01T22:41:25+00:00

Okay I have a an wpf image object, and it displays live images. So

  • 0

Okay I have a an wpf image object, and it displays live images. So I have used a timer to refresh the image.

    public void LoadLiveImage()
        {

System.Windows.Media.PixelFormat pf = PixelFormats.Bgr24;
                    int stride = 4 * ((24 * cameraFrame.img_width + 31) / 32); 
                     BitmapSource bmpImage=  BitmapSource.Create(cameraFrame.img_width, cameraFrame.img_height, cameraFrame.img_width, cameraFrame.img_height, pf, null, cameraFrame.img_pixel, stride);
                    RemoteCameraImage.Source = bmpImage;
}

 void dispatcherTimer_Tick(object sender, EventArgs e)
        {
             LoadLiveImage();           

        }

No issues, this is working fine.
However, I tried to move this to a thread and no image is displayed.

 private void showLiveImage()
        {
                while (this.isCameraViewOpen)
                {
                 if (RemoteCameraImage.Dispatcher.CheckAccess())
                        {
                            System.Windows.Media.PixelFormat pf = PixelFormats.Bgr24;
                            int stride = 4 * ((24 * cameraFrame.img_width + 31) / 32); 
                            BitmapSource bmpImage = BitmapSource.Create(cameraFrame.img_width, cameraFrame.img_height, cameraFrame.img_width, cameraFrame.img_height, pf, null, cameraFrame.img_pixel, stride);
                            RemoteCameraImage.Source = bmpImage;

                            System.Threading.Thread.Sleep(5);
                        }
                        else
                            this.RemoteCameraImage.Dispatcher.Invoke(DispatcherPriority.Normal, new ImageUpdater(this.showLiveImage));

                    }

}

The showLiveImage isrunning as a thread. The image is received, there is not problem in that. I tested by saving the img_pixel array to a bmp file and file is generated. Just that the image is not displayed on. So I put a messagebox to be shown after the source is assigned, and then I m able to see the image on Image object. SO I think the problem I increased the Sleep time, but even the image is not refreshed. WHAT could be the issue?

EDIT:
After moving the code which was updating the image to another function, it works fine. And I used BeginInvoke() instead of invoke an all works fine.

  • 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-01T22:41:26+00:00Added an answer on June 1, 2026 at 10:41 pm

    Sometime ago I had similiar problems and I found this on Stackoverflow, which sovled it for me

    Images on second thread

    WPF Dispatcher {"The calling thread cannot access this object because a different thread owns it."}

    If you have no intention of modifying the image once you have created
    it you can freeze it using Freezable.Freeze and then assign to
    GeneratedImage in the dispatcher delegate (the BitmapImage becomes
    read-only and thus threadsafe as a result of the Freeze). The other
    option would be to load the image into a MemoryStream on the
    background thread and then create the BitmapImage on the UI thread in
    the dispatcher delegate with that stream and the StreamSource property
    of BitmapImage.

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

Sidebar

Related Questions

okay i have found the way to run a video in a image.... the
okay have a this list: object[] test; test[0]=null; .... test[8700]=null; test[8701]= object[] .... test[9431]=
Okay, here's my situation. I have a WPF app that I have created that
Okay so I have a Window in WPF. I add the following line inside
Is it okay to have default constructor which sets some default values like: public
Okay i'm trying to understand WPF and the popular MVVM Pattern. Now i have
Okay here's the situation. Net 4 WPF NO Silverlight. I have several Views that
Okay I have tried everything now. I still can't get my timer to update!...Here
Okay - I have a dilemma. So far my script converts page titles into
okay i have been trying to understand this for hours i am learning VB

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.