c# - Timer for a dictionary -
i have created dynamic timer. time has take time intervals dictionary. when run program says index not exist. , says when y=0;
var timer = new system.windows.forms.timer(); int track = 0; int y = 0; timer.tick += (object sender, eventargs e) => { timer.interval = pqueuvalues[y]; if (track < nodenum) { txtoutput.text += "\r\r\n" + "the node name is: " + normalqueuname[track] + " priority: " + pqueuvalues[track]; ++track; } else { timer.stop(); } }; timer.start();
when use int
key type, dictionary indexes key not numerical position of element. if don't have element key value of 0, fail. can use elementat
method use position index:
timer.interval = pqueuvalues.elementat(y).value;
Comments
Post a Comment