CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Posts
    5

    CoInitialize and CoInitializeEx

    hi, im developing a multithreaded app in NT and i was wondering which would be better for me to use, CoInitialize or CoInitializeEx.

    the multithreaded app uses COM objects but does not share them. each thread has its own COM object so there is no problem with syncronization. i am new to COM so im not too familiar with the threading models, and was wondering if anyone can tell me which i should use to initialize COM.

    also should i initialize COM in the main thread or in each worker thread separately?
    any help would be greatly appreciated
    thanks in advance


  2. #2
    Join Date
    Aug 1999
    Location
    Chicago, IL
    Posts
    43

    Re: CoInitialize and CoInitializeEx

    CoInitialize calls CoInitalizeEx with a flag of COINIT_APARTMENTHREADED. So if you want a multi threaded environment you have to call CoInitalizeEx with the COINIT_MULTITHREADED flag.

    If you are doing an out-of-proc server with the multithreaded flag, be sure not to use any MFC stuff as it only supports apartment threaded stuff.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured