How does it work? Can you give me a sample? As you see I tried something but it doesn't work. my code:
class IPCMsgHandler
{
private Thread listenThread = new Thread(ListeningThreadFunc);
...
public void Start()
{
listenThread.Start(this);
}
private static void ListeningThreadFunc(object data)
{
IPCMsgHandler helper = data as IPCMsgHandler;
...
//helper.OnMessage(); doesn't work...staying in current thread context
MethodInvoker mi = new MethodInvoker(helper.OnMessage);
mi.Invoke();
...
}
}
public class AutoCADApplication : IExtensionApplication
{
IPCMsgHandler helper = null;
public void Initialize()
{
// I have the right execution-context here
this.helper = new IPCMsgHandler("AutoCAD-IPCServer", new IPCMsgHandler.MessageHandler(this.OnIPCMessage));
this.helper.Start();
}
private void OnIPCMessage()
{
// I have the WRONG execution-context here
return;
}