It does from a fresh start of FreeSWITCH. I&#39;ve noticed, although not really confirmed, a race condition between the unload and reload of managed code. It seems that threads started in the newly submodule are terminated along with the threads for the old, unloading submodule. Is that what you are seeing as well?<div>
<br></div><div><div class="gmail_quote">On Wed, Sep 9, 2009 at 2:38 PM, Jeff Lenk <span dir="ltr">&lt;<a href="mailto:jlenk@frontiernet.net">jlenk@frontiernet.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Yeah I noticed that but the thread was still terminating after a few seconds<br>
anyway for me. Does it stay running for you?<br>
<div><div></div><div class="h5"><br>
<br>
Josh Rivers-2 wrote:<br>
&gt;<br>
&gt; A new discovery:        public bool Load()<br>
&gt;         {<br>
&gt;             ThreadPool.QueueUserWorkItem((o) =&gt;<br>
&gt;             {<br>
&gt;                 Log.WriteLine(LogLevel.Notice, &quot;Thread Starting. &quot;);<br>
&gt;                 EventConsumer con = new EventConsumer(&quot;all&quot;, &quot;&quot;);<br>
&gt;                 while (true)<br>
&gt;                 {<br>
&gt;                     Event ev = con.pop(0);<br>
&gt;                     if (ev == null) continue;<br>
&gt;                     Log.WriteLine(LogLevel.Notice, &quot;Event: &quot; +<br>
&gt; ev.serialized_string);<br>
&gt;                 }<br>
&gt;             });<br>
&gt;             return true;<br>
&gt;         }<br>
&gt; Does not crash. (Adding the null check prevents crash.) The backgrounded<br>
&gt; loop runs fine. Looks like the event object goes straight to pinvokes, so<br>
&gt; a<br>
&gt; null result just crashes?<br>
&gt;<br>
&gt; I like the idea of a &#39;startup-script&#39; for mod_managed. It would also be<br>
&gt; excellent if there was an event or message  informing the background code<br>
&gt; to<br>
&gt; terminate nicely when the module reloads.<br>
&gt;<br>
&gt; --Josh<br>
&gt;<br>
&gt; On Wed, Sep 9, 2009 at 12:57 PM, Jeff Lenk &lt;<a href="mailto:jlenk@frontiernet.net">jlenk@frontiernet.net</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; I think the problem here is that the loader only keeps this method in<br>
&gt;&gt; scope<br>
&gt;&gt; until completion then it drops the remoted connection. Therefore you<br>
&gt;&gt; should<br>
&gt;&gt; not use threads in this method. Michael please correct me if I am wrong<br>
&gt;&gt; here.<br>
&gt;&gt;<br>
&gt;&gt; As an example of the failure simply just put a Sleep(10000) call in the<br>
&gt;&gt; thread and you will see the failure.<br>
&gt;&gt;<br>
&gt;&gt; As Michael said this method was only designed to allow the option to opt<br>
&gt;&gt; out<br>
&gt;&gt; of being loaded.<br>
&gt;&gt;<br>
&gt;&gt; In order to support this perhaps a configuration flag simular to the lua<br>
&gt;&gt; &quot;startup-script&quot; should be added.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Here is the error I get with the loop I mentioned. -Josh<br>
&gt;&gt; [image: Capture.PNG]<br>
&gt;&gt;<br>
&gt;&gt; On Tue, Sep 8, 2009 at 5:05 AM, Michael Giagnocavo<br>
&gt;&gt; &lt;<a href="mailto:mgg@giagnocavo.net">mgg@giagnocavo.net</a>&gt;wrote:<br>
&gt;&gt;<br>
&gt;&gt; &gt;  Hi,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;                 Can you please elaborate on the crash you receive when<br>
&gt;&gt; you<br>
&gt;&gt; &gt; queue a thread during load?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Michael<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; View this message in context:<br>
&gt;&gt; <a href="http://n2.nabble.com/Subscribing-to-events-in-managed-C-NET-tp3573619p3613195.html" target="_blank">http://n2.nabble.com/Subscribing-to-events-in-managed-C-NET-tp3573619p3613195.html</a><br>
&gt;&gt; Sent from the freeswitch-users mailing list archive at Nabble.com.<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; FreeSWITCH-users mailing list<br>
&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt;&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; FreeSWITCH-users mailing list<br>
&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt;<br>
&gt;<br>
<br>
</div></div><font color="#888888">--<br>
View this message in context: <a href="http://n2.nabble.com/Subscribing-to-events-in-managed-C-NET-tp3573619p3614845.html" target="_blank">http://n2.nabble.com/Subscribing-to-events-in-managed-C-NET-tp3573619p3614845.html</a><br>

</font><div><div></div><div class="h5">Sent from the freeswitch-users mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</div></div></blockquote></div><br></div>