Solved

The calling thread cannot access the object becuase a different thread owns it

Posted on 2014-01-24
3
253 Views
Last Modified: 2014-02-07
I have a WPF MVVM application.
I have this particular piece of code which gives the above error.

It is triggered whn a button is clicked and works fine the first time the button is clicked.
But the next time arround on the second button click I get the error.
PivotGrid is an UI element in my view, and I am accessing the UI element in my Viw Model

 Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(
                  delegate()
                  {
                      pivotGrid = App.Current.Windows[0].FindName("pivotGrid") as PivotGridControl;

                  }));
0
Comment
Question by:countrymeister
3 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 39809349
Check out this thread, I think it's related to your problem: http://stackoverflow.com/questions/1226443/how-to-access-a-wpf-object-in-the-dispatcher
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39825834
Can you post a sample project that also encounters the same issue,
0
 
LVL 1

Author Closing Comment

by:countrymeister
ID: 39841812
helped a little
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question