using System;
using System.Linq;
using Microsoft.Practices.Prism.MefExtensions.Modularity;
using Samba.Domain.Models.Customers;
using Samba.Localization.Properties;
using Samba.Persistance.Data;
using Samba.Presentation.Common;
using Samba.Presentation.Common.Services;
using System.Threading;
namespace Samba.Modules.TapiMonitor
{
[ModuleExport(typeof(TapiMonitor))]
public class TapiMonitor : ModuleBase
{
public TapiMonitor()
{
Thread thread = new Thread(() => OnCallerID());
thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
thread.Start();
}
public void CallerID()
{
InteractionService.UserIntraction.DisplayPopup("CID", "CID Test 2", "", "");
}
public void OnCallerID()
{
this.CallerID();
}
}
}
我试图添加一些东西到C#中的开源软件包,但我遇到了问题。上述(简化)示例的问题是,一旦调用了InteractionService.UserIntraction.DisplayPopup,我就会得到一个异常“调用线程无法访问此对象,因为不同的线程拥有它”。C#WPF从工作线程更新UI
我不是C#编码器,但我已经尝试了很多事情来解决这个问题,如委托人,BackgroundWorkers等等,迄今为止还没有人为我工作。
有人可以帮我吗?
什么是东西。 Interaction.DisplayPopup代码在哪里?一个代表应该能够解决的问题 – 2013-02-22 10:20:28
相关:http://stackoverflow.com/questions/11923865/how-to-deal-with-cross-thread-access-exceptions – 2013-02-22 14:29:44