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();
}
}
}
I'm trying to add something to a opensource software package made in C# but I'm having problems with it. The problem with the above (simplified) example is that once InteractionService.UserIntraction.DisplayPopup is called I get an exception "The calling thread cannot access this object because a different thread owns it".
I am not a C# coder but I have tried many things to solve this like Delegates, BackgroundWorkers, etc. etc. and none have worked for me so far.
Can anybody help me with this?