Hi, you are fireing the events in class evento in it's constructur. That way
all events will have been fired before the Main-Method reaches
e.TerminoBucle += new EventHandlerIniciar2(handler);
So the events does not have an consumer and no actions will occure.
In generall I don't know how to catch events fired in the constructor of a new
instanciated class. In my opinion a separate Start Method would be best, that
way you can register your consumers to the event before they will be fired.
Kind Regards,
Valentin.
On Saturday 16 September 2006 06:45, Lord Steve Ataucuri Cruz wrote:
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
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list