c# - Timer is triggering event on another instance of my Form -


i have multiple instances of same dialog. pass in enum dialog knows information display. have timers within form trigger actions (in case button click example). however, when these timers trigger, caught 1 (and last form created) , not other forms. form triggered timer catch it. missing?

public partial class form1 : form {     public enum animal { cat, dog, pig };     public form1()     {         initializecomponent();          form2 f21 = new form2(animal.cat);         f21.show();          form2 f22 = new form2(animal.dog);         f22.show();          form2 f23 = new form2(animal.pig);         f23.show();     }  public partial class form2 : form {     int buttoncount = 0;     form1.animal animal;     private static system.threading.timer refreshlistviewtimer;      public form2(form1.animal theanimal)     {         initializecomponent();         animal = theanimal;         text = theanimal.tostring();         refreshlistviewtimer = new system.threading.timer(onrefreshlisttimer);     }      private void button1_click(object sender, eventargs e)     {         refreshlistviewtimer.change(50, system.threading.timeout.infinite);     }      private void onrefreshlisttimer(object sender)     {         if (!this.isdisposed)             invoke(new refreshlistdelegate(this.refreshlist), new object[] { });     }      private delegate void refreshlistdelegate();     private void refreshlist()     {         buttoncount++;         text = this.animal.tostring() + " " + buttoncount.tostring();     } } 

in case, no matter form click button, pig dialog incremented.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -