Click here to Skip to main content
15,914,452 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear Geeks,

I've created a wpf library, where i'm creating a windows and displaying some data. I've added this library to my Application. But while updating the window i'm getting error "The calling thread cannot access this object because a different thread owns it.". I tried some solution provided by experts in net. still not able to fix the issue. I'm a beginner in wpf. Please help me.

My code looks like

C#
Main()
{
  MyDllClass obj =  new MyDllClass();
  obj.ShowMyDlg(); 
}


MyDllClass class is a class in dll (wpf) and in ShowMyDlg I'm creatinga timer and updating some control in Window.

Regards,
Vid
Posted
Comments
Thomas Duwe 10-Sep-12 7:33am    
I suppose you are creating a Task or background thread in the MyDllClass and from this Task/background thread you access some properties/controls of the UI.

If that's the case then find further information here:
http://www.codeproject.com/Articles/37314/Useful-WPF-Threading-Extension-Method

1 solution

This error generally comes because of threading deadlock. try to call your code in Dispatcher.
this will help the code to execute on different thread and your problem will be solved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900