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# コーダーではありませんが、Delegates、BackgroundWorkers など、これを解決するために多くのことを試しましたが、これまでのところうまくいきませんでした。
誰でもこれで私を助けることができますか?