CoUninitialize() hangs

Started by
3 comments, last by BauerGL 20 years ago
I have a strange problem with CoUninitialize(). It only happens if I use CoInitialize/Ex() and then initializes the server or adapter object. By just calling CoInitialize() and then CoUninitialize() everything works fine. For some reason it hangs my server, though my client works fine. I''m doing the exact same thing on the client and the server, the only difference is the use of client/server objects. One other note is that the server is a console app while the client is a win32 app. I am absolutely clueless about this so I''m wondering if any of you have encountered this problem before or if you have any tips to give away. Thanks for reading.

@mikaelbauer

Super Sportmatchen - A retro multiplayer competitive sports game project!

Advertisement
I am not sure, but have you tried CoInitializeEx(NULL, COINIT_MULTITHREADED)? might be something related to threading model.
not sure, just an advise
Yea that''s the one I''m using (sorry, I see that it wasn''t clear in my previous post.)

I believe that the problem occurs on the client as well now.. it fails to shutdown (i.e it hides in the task manager) on CoUninitialize().

@mikaelbauer

Super Sportmatchen - A retro multiplayer competitive sports game project!

First: the kernel will uninitialize for you. Just don''t worry about it. ExitProcess() is the quickest way to quit your game, so use it without wasting time on closing and deleting objects. The kernel will clean up -- that''s it''s main job!

Second: if you want to CoUninitialize() for some reason (random aesthetics? provable leak-free-ness?) then you must make sure that all references to all interfaces that your process holds are first released. This includes references that some library you''re using may hold.

The reason you''re hanging is probably this (from MSDN documentation):
quote:
If there are open conversations remaining, CoUninitialize starts a modal message loop and dispatches any pending messages from the containers or server for this COM application. By dispatching the messages, CoUninitialize ensures that the application does not quit before receiving all of its pending messages.

enum Bool { True, False, FileNotFound };
Yeah, you need a message pump.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement