Boost logo

Boost Users :

Subject: Re: [Boost-users] [ASIO] Where to use CoInitizeEx
From: Daniele Barzotti (daniele.barzotti_at_[hidden])
Date: 2009-06-03 09:21:47


Igor R ha scritto:
>>
>> My question is: where I have to call CoInitizeEx?
>
> You can start the threads with your own thread-function (instead of
> io_service::run) that would call CoInitialize(), io_service::run(),
> CoUninitialize().

Thanks a lot Igor!
It was simple...and I didn't thought :-)
Now seems to work:

void io_worker_thread(void)
{
#if (WIN32)
  CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
#endif

  io_service.run();

#if (WIN32)
  CoUninitialize();
#endif
};

EXTERN_C EUROATLIB_API TETRAMotoHndl CALL GetTETRAMotoObj()
{
 ....
 // run the IO service as a separate thread

 //io_service_thread.reset(
 // new boost::thread(
 // boost::bind(&boost::asio::io_service::run, &io_service)
 // )
 //);

 io_service_thread.reset(new boost::thread(io_worker_thread));

 ...
};

Thanks!
Daniele.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net