0

I have a class named MifareReader. I instantiate it as Global So i Have on my form_load:

MifareReader mf = new MifareReader()

private void Main_Load(object sender, EventArgs e)
{
   mf.MyEvent += new EventName(My_Method);
   Connect();  
}

private void My_Method()
{
  //Code Here
}

private void Connect()
{
  //Some Code Here
  mf.MyEvent += new EventName(My_Method); //The same code of the Main_Load
}

Now let me explain. On my Main_Load I've set the event MyEvent and set it's method to My_Method Right ? Also, I called the other method Connect(), this methods repeat what i've done on the Main_Load

mf.MyEvent += new EventName(My_Method);

Right ?

So, I don't know why, but if I do not repeat this code, the application DOES NOT fire the MyEvent without Closing/Reopening the application.

Ok, its working perfect the way it is, but when I close/reopen my application, it fires MyEvent twice. So, Is there a way to work around this ?
Maybe check if the mf.MyEvent has already a method set to it?

Ghaleon
  • 1,186
  • 5
  • 28
  • 55
  • check [StackOverflow Question](http://stackoverflow.com/questions/1129517/c-sharp-how-to-find-if-an-event-is-hooked-up) – ram2013 Jun 21 '13 at 18:32
  • 1
    It's possible verify if a method was set in a event, but first let me ask: If you delete the first set in `Main_Load` what happens? – Jonny Piazzi Jun 21 '13 at 18:35
  • @JonnyPiazzi My method `Connect()` is responsible to set a my rfdi device's configuration and save it on my app.config. I thought that, when there were already a config set, it would be necessary to have that code on my Main_Load. But it worked perfect removing that, Thank you Jonny !!!!! +1 – Ghaleon Jun 21 '13 at 18:43

0 Answers0