Click here to Skip to main content
15,920,828 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Depcrecated stl-streams Pin
Christian Graus4-Dec-02 9:43
protectorChristian Graus4-Dec-02 9:43 
GeneralRe: Depcrecated stl-streams Pin
Taka Muraoka5-Dec-02 16:09
Taka Muraoka5-Dec-02 16:09 
QuestionATL 7: How to _Module.GetModuleInstance()? Pin
Binky3-Dec-02 5:49
Binky3-Dec-02 5:49 
AnswerRe: ATL 7: How to _Module.GetModuleInstance()? Pin
geo_m4-Dec-02 3:25
geo_m4-Dec-02 3:25 
GeneralNeed help in firing event from second thread using shared variable!! Pin
bahruddina3-Dec-02 5:29
bahruddina3-Dec-02 5:29 
GeneralRe: Need help in firing event from second thread using shared variable!! Pin
geo_m5-Dec-02 1:14
geo_m5-Dec-02 1:14 
GeneralRe: Need help in firing event from second thread using shared variable!! Pin
bahruddina6-Dec-02 20:16
bahruddina6-Dec-02 20:16 
GeneralRe: Need help in firing event from second thread using shared variable!! Pin
geo_m6-Dec-02 22:34
geo_m6-Dec-02 22:34 
Goood morning there Wink | ;)

OK, I think I get it. It wasn't too difficult. But first, what I meant by the "the pointers you are using there should be unmarshalled". I saw a people making code like that:

pseudo

MarshalInterface
start thread
Unmarshal Interface to member m_spCorrect;
use completely another member like m_vec.GetAt directly from the new thread (therefore need marshalling but not used on this pointer).

But this was not your case.

Your problem is hidden in, say unrelated, method CIBMSSchedule::Run. Here you have somewhere about line 111 command Sleep(5000); and this is that one causes your problems. How marshalling works is, very shortly, that if he needs to transfer call from thread A to thread B, (s)he/it uses a old plain window messages. Then all threads in STA (you are using) must have the message pump to work correctly.

Then replace your Sleep(5000) with something like:

<br />
MSG msg;<br />
while( ::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )<br />
{<br />
	BOOL bRet = ::GetMessage(&msg, NULL, 0, 0);<br />
<br />
	::TranslateMessage(&msg);<br />
	::DispatchMessage(&msg);<br />
	<br />
}<br />


and then your code started to work for me (Event received at VB client).
Some another notes:
- consider to somehow remove the Sleep design pattern Wink | ;) .
- I see that you are adding thread for each client, but didn't see the remove mechanism (might be my fault, didn't check it too carefully Wink | ;) )
- hint: I believe (as I don't work with exe components), that for remove this marshalling pains, you can use CoInitializeEx(NULL,COINIT_MULTITHREADED); for free threading. Then it behaves like normal threads and no need for marshaling (only between VB and VC). Then you don't need to carry about, as the _tWinMain already contains the msg pump doing that.

Hope this helps & enjoy
GeneralRe: Need help in firing event from second thread using shared variable!! Pin
bahruddina7-Dec-02 6:34
bahruddina7-Dec-02 6:34 
GeneralRe: Need help in firing event from second thread using shared variable!! Pin
geo_m7-Dec-02 7:04
geo_m7-Dec-02 7:04 
GeneralRe: Need help in firing event from second thread using shared variable!! Pin
bahruddina7-Dec-02 21:23
bahruddina7-Dec-02 21:23 
GeneralRe: Need help in firing event from second thread using shared variable!! Pin
geo_m7-Dec-02 21:34
geo_m7-Dec-02 21:34 
Generalhandling events Pin
Dezz3-Dec-02 0:09
Dezz3-Dec-02 0:09 
GeneralATL attributed programming, need help! Pin
xi90430-Nov-02 15:56
xi90430-Nov-02 15:56 
GeneralRe: Is there an ATL equivalent for MFC's CObArray? Pin
Rene De La Garza30-Nov-02 7:52
Rene De La Garza30-Nov-02 7:52 
QuestionHow to implement a schedule in VC++ Pin
Anonymous29-Nov-02 21:45
Anonymous29-Nov-02 21:45 
AnswerRe: How to implement a schedule in VC++ Pin
Christian Graus29-Nov-02 22:15
protectorChristian Graus29-Nov-02 22:15 
AnswerRe: How to implement a schedule in VC++ Pin
geo_m4-Dec-02 3:35
geo_m4-Dec-02 3:35 
GeneralLinker error Pin
Paul Ingles28-Nov-02 10:46
Paul Ingles28-Nov-02 10:46 
GeneralRe: Linker error Pin
Rene De La Garza28-Nov-02 10:54
Rene De La Garza28-Nov-02 10:54 
GeneralRe: Linker error Pin
Paul Ingles28-Nov-02 11:21
Paul Ingles28-Nov-02 11:21 
GeneralDeallocation of Queue Memory Pin
Rizi28-Nov-02 5:33
Rizi28-Nov-02 5:33 
GeneralRe: Deallocation of Queue Memory Pin
Nick Parker28-Nov-02 6:36
protectorNick Parker28-Nov-02 6:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.