<br><div class="gmail_quote">On Wed, Jun 3, 2009 at 12:45 PM, Igor R <span dir="ltr">&lt;<a href="mailto:boost.lists@gmail.com">boost.lists@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">&gt; When the SerialPort receive data, pass it to the ATDispatcher that<br>
&gt; raises a signal to the TETRAMoto object that parses the data and raise<br>
&gt; the event (always a signal) to the extern:<br>
&gt;<br>
&gt; asio::serial_port -&gt; SerialPort -&gt; ATDispatcher -&gt; TetraMoto -|-&gt; EXTERN<br>
&gt;<br>
&gt; Now I have to encapsulate this lib into an ActiveX DLL to be used by VB6<br>
&gt; and I have to call CoInitizeEx in the thread that &quot;raise&quot; events..<br>
&gt;<br>
&gt; My question is: where I have to call CoInitizeEx?<br>
<br>
</div>You can start the threads with your own thread-function (instead of<br>
io_service::run) that would call CoInitialize(), io_service::run(),<br>
CoUninitialize().</blockquote><div><br><br>If you don&#39;t start the threads from the global scope (after the main has been entered)<br>you may use the Schwarz-Counter (also known as Nifty-Counter) idiom.<br><br>It is well described here: <a href="http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Nifty_Counter">http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Nifty_Counter</a><br>
<br>This is how Jerry Schwarz implemented the thread safe initialization of global iostream objects in STL:<br>cout, cerr, clog etc.<br><br>Regards,<br>Ovanes<br> </div></div><br>

