从dll显示和更新对话框 [英] Display and updating dialog from dll

查看:72
本文介绍了从dll显示和更新对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的Geeks,



我已经创建了一个wpf库,我正在创建一个窗口并显示一些数据。我已将此库添加到我的应用程序中。但是在更新窗口时我得到错误调用线程无法访问此对象,因为不同的线程拥有它。。我尝试了网络专家提供的一些解决方案。仍然无法解决问题。我是wpf的初学者。请帮帮我。



我的代码看起来像



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

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





MyDllClass类是dll(wpf)和ShowMyDlg中的一个类我正在创建一个计时器并更新一些控制在窗口。



问候,

Vid



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

Regards,
Vid

推荐答案

此错误通常是因为线程死锁而来。尝试在Dispatcher中调用您的代码。

这将有助于代码在不同的线程上执行,您的问题将得到解决。
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.


这篇关于从dll显示和更新对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆