[Mono-list] multiple targets with delegates

Chris Turchin chris@turchin.net
14 Aug 2003 21:45:36 +0200


Hi, 

based on the code from this post, i experimented further and the
following code creates an infinite loop in mono but in .net (1.1
framework) runs only once and then exits. Who is right?

Regards,
--chris


using System;
namespace rohit
{
	
	public delegate void func();
	
	public class publisher
	{
		public publisher(){}
		public   func onfunc;
		public void fire()
		{
			System.Console.WriteLine("your're fired!");
			onfunc.BeginInvoke(null,null);
		}
	}
	
	public class mymain
	{
		public static void Main()
		{
			publisher pub= new publisher();
			//delegate fire to itself and call it...
			pub.onfunc+= new func(pub.fire);
			pub.fire();
		}
	}

}



On Tue, 2003-08-12 at 20:09, Rohit wrote:
> Hi,
>  This is my very first post to the list and i would
> like to pass on my very warm wishes for the great
> project we are working on.
> 
> While starting off with mono I have some doubts like
> 
> If i create a delegate with multiple targets and call
> BeginInvoke on the delegate I get different behaviour
> in .Net and Mono. Please see the attached file. .Net
> does not allow to call BeginInvoke and gives a run
> time exception, while Mono has no problems. 
> 
> 
> Do we have System.Net, can i get any sample as to how
> to put my network card into promiscuous mode?
> Since i couldn't run monodoc and go-mono didnt work
> for me i need to find out if we have
> System.Net.Sockets working for us ?
> 
> When i run monodoc i get this output
> 
> ** (<unknown>:1444): WARNING **: Failed to load
> library ./libgtkhtml-3.0.so.2 (libgtkhtml-3.0.so.2):
> ./libgtkhtml-3.0.so.2: cannot open shared object file:
> No such file or directory
> 
> ** (<unknown>:1444): WARNING **: Missing method
> AppendColumn in assembly browser.exe typeref index 34
> 
> Unhandled Exception: System.NullReferenceException: A
> null value was found where an object instance was
> required
> in (unmanaged) 00 .TreeBrowser:.ctor
> (RootTree,Gtk.TreeView,Browser)
> in <0x001c3> 00 .Browser:.ctor ()
> in <0x0017b> 00 .Browser:Main (string[])
> 
> i have the libgtkhtml.so. files and i did ldconfig but
> still i get the above warning? 
> 
> thanks
> rohit
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> 
> ______________________________________________________________________
> using System;
> 
> namespace rohit
> {
> 
> public delegate void func();
> public class publisher
> {
> 
> 
> 
> public   func onfunc;
> public publisher()
> {
> 
> 
> }
> 
> public void callme()
> {
> System.Console.WriteLine("am called");
> }
> 
> public void callmetoo()
> {
> 
> System.Console.WriteLine("me too called");
> }
> 
> 
> public void fire()
> {
> onfunc.BeginInvoke(null,null);
> }
> 
> }
> 
> 
> 
> public class mymain
> {
> 	public static void Main()
> 	{
> 		publisher pub= new publisher();
> 		pub.onfunc+= new func(pub.callme);
> 		pub.onfunc+= new func(pub.callmetoo);
> 		
> 		pub.fire();
> 	}
> }
> 
> }