Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STA concurrency - GetMessage loop problems

Status
Not open for further replies.

Vitally

Programmer
Oct 17, 2005
1
MD
Urgent!!!
Hi!
I have a completely weird problem, at least for me, regarding connection
points, STA model and GetMessage function.

I have an Out-ofProc server (EXE), singleton running in an STA, with one ATL object - CClientEx. Server fires connection point events to sinks IClientExEvents using Fire_HelloClient;

Also I have 2 different applications (let say AppA and AppB) both are using STA model that make CoCreateInstance to my CClientEx.
AppA have no Advise implementation only AppB has. So simply what my Server needs to do is to trasfer call from AppA to AppB thru its IConnectionPointImpl.
When my AppA starts sending messages through the server AppB should get the message, do somth. with it and then send response to AppA.
The problems is that I can have multiple instaces of AppA and I wont AppB to respond to them synchronizing, one at a time as they arrives.
So I'm using in my main proces GetMessage to get event notification.
while (GetMessage(&msg, 0, 0, 0)>0)
{
DispatchMessage(&msg);
}
But when more then one AppA are sending messages thru the server my AppB (which is unique) gets calls on method Fire_HelloClient (my callback objectEvents interface immplementation for HelloClient) from the server despite the used STA model and GetMessage loop in the same main thread ID, as many as AppA applications are. Even if set a MessageBox in my Fire_HelloClient to stop the thread which came first, Im getting messages from others AppB which access my class members and many of this stop MessageBoxes appears.
Shouldnt GetMessage loop help me or even STA model prevent such problem !
Please help me,
Im a newbie!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top