[Freeswitch-users] Subscribing to events in managed C# / .NET

Jeff Lenk jlenk at frontiernet.net
Thu Sep 10 07:33:44 PDT 2009


Thanks Michael,

I was seeing some strange behavior in a static compiled dll versus
dynamically loaded and compiled scripts.

This code when used in a dll was blowing up when a thread was spawned in the
ILoadNotificationPlugin.Load but is not when used in a dynamically loaded
script(csx).

Code: 

	ThreadPool.QueueUserWorkItem((o) =>
	{
		Log.WriteLine(LogLevel.Notice, "Thread Starting. ");
		while (true)
		{
		   Thread.Sleep(10000);
                             Log.WriteLine(LogLevel.Notice, "Thread Running.
");
		}
            });

I will look into this more later.

Jeff



Michael Giagnocavo wrote:
> 
> The ILoadNotifcationPlugin is run in the appdomain created for the plugin,
> so it should only get unloaded when the plugin gets reloaded. Spawning
> threads here should work, it's definitely the intention that if you need a
> long-running process, you can fire it up on load and have it work.
> 
> As to the race condition on reload, mod_managed should do this:
> 
> 	- Load the new plugin into a new appdomain
> 	- Remove the entry points to the old appdomain, add entries to the new
> one
> 	- Old appdomain now stays alive until foreground API and APP calls finish
> 
> So, you can have many versions of the same plugin active in memory. 
> 
> I probably need to go break compatibility and make ILoadWhateverPlugin be
> something like IPluginController and allow it to return loading options to
> control the mod_managed behavior, as well as allow it to delay shutdown of
> the appdomain. Part of the question is: how many people out there need
> compatibility, or can we go breaking all of you and make you recompile? :)
> 
> Although, IIRC, if you handle AppDomain.Unload (or whatever it is), it
> will stay alive until your event handler completes. 
> 
> Hope that helps a bit.
> 
> -Michael
> 
>  
> -----Original Message-----
> From: freeswitch-users-bounces at lists.freeswitch.org
> [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Jeff
> Lenk
> Sent: Wednesday, September 09, 2009 1:57 PM
> To: freeswitch-users at lists.freeswitch.org
> Subject: Re: [Freeswitch-users] Subscribing to events in managed C# / .NET
> 
> 
> I think the problem here is that the loader only keeps this method in
> scope
> until completion then it drops the remoted connection. Therefore you
> should
> not use threads in this method. Michael please correct me if I am wrong
> here.
> 
> As an example of the failure simply just put a Sleep(10000) call in the
> thread and you will see the failure.
> 
> As Michael said this method was only designed to allow the option to opt
> out
> of being loaded.
> 
> In order to support this perhaps a configuration flag simular to the lua
> "startup-script" should be added.
> 
> 
> 
> Here is the error I get with the loop I mentioned. -Josh
> [image: Capture.PNG]
> 
> On Tue, Sep 8, 2009 at 5:05 AM, Michael Giagnocavo
> <mgg at giagnocavo.net>wrote:
> 
>>  Hi,
>>
>>
>>
>>                 Can you please elaborate on the crash you receive when
>> you
>> queue a thread during load?
>>
>>
>>
>> Thanks,
>>
>> Michael
>>
>>
> 
> -- 
> View this message in context:
> http://n2.nabble.com/Subscribing-to-events-in-managed-C-NET-tp3573619p3613195.html
> Sent from the freeswitch-users mailing list archive at Nabble.com.
> 
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
> 
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
> 
> 

-- 
View this message in context: http://n2.nabble.com/Subscribing-to-events-in-managed-C-NET-tp3573619p3617527.html
Sent from the freeswitch-users mailing list archive at Nabble.com.




More information about the FreeSWITCH-users mailing list