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

  • Home
  • SEARCH
  • 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 8371093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:04:54+00:00 2026-06-09T14:04:54+00:00

A common exception one can get when working with multiple threads in WPF is:

  • 0

A common exception one can get when working with multiple threads in WPF is:

The calling thread cannot access this object because a different thread owns it

What are the options to deal with this properly?

  • 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-09T14:04:55+00:00Added an answer on June 9, 2026 at 2:04 pm

    Depending on the situation there are various options:

    Accessing a control from another thread

    e.g. updating a TextBlock with progress information.

    • Data Binding:

      In this case the easiest thing you can do is avoiding the direct interaction with the control. You can just bind the property you want to access or modify to an object whose class implements INotifyPropertyChanged and then set the property on that object instead. The framework will handle the rest for you. (In general you rarely should need to interact with UI-elements directly, you can almost always bind the respective properties and work with the binding source instead; one case where direct control access may be necessary is control authoring.)

      There are some cases where data binding alone is not enough, for example when trying to modify a bound ObservableCollection<T>, for this you need…

    • Dispatching:

      You can dispatch your accessing code to the thread owning the object, this can be done by calling Invoke or BeginInvoke on the Dispatcher owning the object being accessed (getting this Dispatcher is possible on another thread).

      e.g.

      new Thread(ThisThreadStart).Start();
      
      void ThisThreadStart()
      {
          textBlock.Dispatcher.Invoke(new Action(() => textBlock.Text = "Test"));
      }
      

      If it is not clear on which thread a method is executed you can use Dispatcher.CheckAccess to either dispatch or execute an action directly.

      e.g.

      void Update()
      {
          Action action = () => myTextBlock.Text = "Test";
          var dispatcher = myTextBlock.Dispatcher;
          if (dispatcher.CheckAccess())
              action();
          else
              dispatcher.Invoke(action);
      }
      

      If an object is not a DispatcherObject and you still need the associated Dispatcher you can use Dispatcher.CurrentDispatcher in the thread creating the object (so doing this in the method being executed by a thread will not do you any good). For convenience as you usually create objects on the application’s main UI thread; you can get that thread’s Dispatcher from anywhere using Application.Current.Dispatcher.

    Special cases:

    • BackgroundWorker

      Move any control access to ProgressChanged as it occurs on the thread that created the instance (which should of course be the UI-thread)

    • Timers

      In WPF you can use the DispatcherTimer for convenience, it does the dispatching for you so any code in Tick is invoked on the associated dispatcher. If you can delegate the dispatching to the data binding system you of course can use a normal timer as well.

    You can read more about how the Dispatcher queue works and WPF threading in general on MSDN.

    Accessing an object created on another thread

    e.g. loading an image in the background.

    If the object in question is not Freezable you should in general simply avoid creating it on another thread or restricting access to the creating thread. If it is Freezable you just need to call Freeze to make it accessible to other threads.

    Accessing a data object from another thread

    That is, the type whose instance is being updated is user-code. If an exception is thrown this situation probably came about by someone using DependencyObject as base type for a data class.

    This situation is the same as accessing a control and the same approaches can be applied but usually it should be avoided in the first place. Granted, this allows for simple property change notifications via dependency properties and those properties can also be bound but often enough this is just not worth giving up thread-independency. You can get change notifications from INotifyPropertyChanged and the binding system in WPF is inherently asymmetrical, there always is a property that is bound (target) and something that is the source for this binding. Usually the UI is the target and the data is the source, meaning that only UI components should need dependency properties.

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

Sidebar

Related Questions

When I execute the code below, I get the common exception The process cannot
I can't quite figure this one out. To make it simple I'll explain what
I have found that one common reason for the error is an exception being
I was wondering, what is the common way to log exception, if message is
Common problem I'm sure, but I can't figure it out. In my AndroidManifest.xml and
A common issue I have is getting confused what $(this) is referring to. I
Most common ORMs implement persistence by reachability, either as the default object graph change
I'm working on an application where I have a plugin-style architecture with multiple abstract
In OpenGL, one often writes code like this: glPushMatrix(); // modify the current matrix
I'm implementing some dialogs that need a common poll to get fresh values from

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.