[Mono-dev] Why Event not actived

Lord Steve Ataucuri Cruz sataucuri at gmail.com
Sat Sep 16 00:45:14 EDT 2006


hello, people
Thanks for its time

I am making a software and I have a class with events and I want to know
because the events in chain do not ariser? I have declared classes and what
I want to know he is because when I call to these events do not go off in
chain, something I am making bad? or deberia to make it of another form.

using System;


public delegate void EventHandlerIniciar(object sender, EventArgs a);
public delegate void EventHandlerIniciar2(object sender, EventArgs a);

public class cosa{

  public event EventHandlerIniciar termino;

  public void iniciar(){
    for(int i=0;i<=100;i++)
      if(i==100){
            surgioevento();
            Console.WriteLine("ok1");
     }
  }

  public void surgioevento(){
    if(termino!=null)
      termino(this,new EventArgs());
  }
}


public class evento{
       public event EventHandlerIniciar2 TerminoBucle;

       public evento()
       {
             cosa c = new cosa();
             c.termino += new EventHandlerIniciar(handler);
             c.iniciar();
       }

       public  void handler(object sender,EventArgs a)
       {
             Console.WriteLine("ok2");
             if (TerminoBucle != null){
                    TerminoBucle(this, new EventArgs());
                    Console.WriteLine("ok3");
             }
       }

}


public class evento2{

       static void Main(){
           evento e = new evento();
           e.TerminoBucle += new EventHandlerIniciar2(handler);

       }

       private static void handler(object s, EventArgs e){
            Console.WriteLine("ok4");

       }
 }


thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060916/7bef9e5f/attachment.html 


More information about the Mono-devel-list mailing list