Re: MTA, STA show no change in concurency
Wizard shows 4 types of threading models, I tried with all just
because nothing seemed to make difference at all.
1) I stepped in to ATL implementation, RegisterClassObjects() is
being passed following...
hr = RegisterClassObjects( ,4 /*CLSCTX_LOCAL_SERVER*/, 1 /
Again, what matters is which apartment RegisterClassObjects is called
_from_. In other words, which flavor of CoInitialize[Ex] the calling
2) Ctor of CAtlExeModuleT() calls CoInitialize()
.... unless _ATL_FREE_THREADED macro is defined, then it calls
and could not step in
to exact line using debugger.
Then I added _WIN32_DCOM & _ATL_FREE_THREADED defines. But this did
not change anything.
Added where and how?
I also tried calling CoInitialize(MULT...) from main() and that also
did not bring any change to behaviour.
extern "C" int WINAPI _tWinMain(HINSTANCE, , LPTSTR, int nShowCmd)
HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED); //Did not
change threading behaviour at all.
Have you checked the return code? Since _AtlModule is a global variable,
its constructor runs before WinMain, and initializes COM on the main
thread. When you are calling CoInitialize[Ex] the second time on the
same thread, it likely fails.
Do you see anything wrong in my approch, outside of COM, like the way
threads are being launched etc?
Not in what you've shown. I still suspect that your server actually runs
STA in all cases. The symptoms are certainly consistent with this
With best wishes,
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925