G
Guest
I'm updating a .NET DLL that is used by a windows app.
Unfortunatly I can't change the windows app, just my DLL.
I want to run most of my code in a different thread
(for multiple reasons...) but a vendor API that my DLL
uses requires a message pump for an internal timer.
I wrote a test program to prototype this. It's an EXE (windows app)
which instantiates an object from a seperate DLL, which starts
a new thread, which then calls Application.Run(new HiddenForm()).
You get the idea. I spit out some info to the console and confirmed
that each window is running in a seperate thread and that each thread
has it's own message pump.
When I make a call from the window generated by the EXE to the window
generated by the DLL, I have to use BeginInvoke or it throws an error.
(I'm guessing the error is thrown because the DLL window is not receiving
any messages from the message pump on the first thread.)
However, if I raise an event from the DLL's window to the EXE's window, it
DOES NOT throw an error, even though the EXE window is receiving messages
from the second thread's message pump.
I thought I would have to use BeginInvoke to get the event to "jump"
over to the first thread just like I had to use BeginInvoke to get the
function call
from the EXE to "jump" to the DLL's thread.
Is the EXE window receiving messages from BOTH message pumps??
How can that be?
Am I missing something here??
Thanks!
Steve
Unfortunatly I can't change the windows app, just my DLL.
I want to run most of my code in a different thread
(for multiple reasons...) but a vendor API that my DLL
uses requires a message pump for an internal timer.
I wrote a test program to prototype this. It's an EXE (windows app)
which instantiates an object from a seperate DLL, which starts
a new thread, which then calls Application.Run(new HiddenForm()).
You get the idea. I spit out some info to the console and confirmed
that each window is running in a seperate thread and that each thread
has it's own message pump.
When I make a call from the window generated by the EXE to the window
generated by the DLL, I have to use BeginInvoke or it throws an error.
(I'm guessing the error is thrown because the DLL window is not receiving
any messages from the message pump on the first thread.)
However, if I raise an event from the DLL's window to the EXE's window, it
DOES NOT throw an error, even though the EXE window is receiving messages
from the second thread's message pump.
I thought I would have to use BeginInvoke to get the event to "jump"
over to the first thread just like I had to use BeginInvoke to get the
function call
from the EXE to "jump" to the DLL's thread.
Is the EXE window receiving messages from BOTH message pumps??
How can that be?
Am I missing something here??
Thanks!
Steve