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