I have 2 process that I want to enable multithreaded communication between them.
Both process are STA because they contains a web browser control (active x).
My scenario is this:
- Process 1: send a message to process 2 and wait for return
- Process 2: send a message to process 1 (not as return value, a different message)
- Process 1: return a result for process 2 message
- Process 2: return a result for process 1 message
When I try to perform step 2 the process 2 hangs because process 1 main thread waiting for the result.
I’m using named pipes for the communication but I’m open to any other communication method (“real” communication, not shared memory).
What I’m looking for is that a new thread will be open in process 1 when the main thread (or any other thread) is waiting for response.
I have to use the main thread to perform the call because it originally initiated from the web browser control (using “object for scripting”).
If there is a way to “move” the call stack of the main thread to another thread (and then return it to the main thread to comunicate with the web browser) it will be a possible solution.
You can find my code example here (VS 2010):
http://www.filedropper.com/interprocesscomunicationusingwithwebbrowser
Debugging this situation can be tricky. You need to run InterProcessComunicationUsingWithWebBrowser2 before you run InterProcessComunicationUsingWithWebBrowser, then put a break point in line 40 (return Sender.SendMessage(ProcessNamedPipes.Process2, "hello") + Guid.NewGuid().ToString("n");) in Form1.cs
I found a solution! i changed the app to be MTA and created the Browser form in a new STA thread