Oh briliant, thank you. I spent two days trying to get my dogs run slow, with timer.
I kept on turning at Type Write example, but I was not able to do it. I want to use timer in RACE button event instead of adding Tick event and Enabled property of Timer was set to true.
I believe that gave me a problem. When I start the debugger, the first method to be invoked was RACE button event in that case.
Then I changed Enabled=True to false in Timer object propert
y. And to run the debugger. It started normal. But dogs were running super fast although I set the interval to 5000..... I knew the following code has something missing. But I was not sure how to fix it with proper understanding.
private void btnRace_Click(object sender, EventArgs e)
btnBet.Enabled = false ;
for (i = 0; i < Dogs.Length; i ++)
MessageBox.Show("We have a winner! Dog #" + i);
Winner = i;
isWon = true;
1. I am just curious to know how I could set Ticker into RACE button instead of having Tick event. Is it possible? If so what mistake did I do? Oh perhaps it's meant to invoke 'first method in an application' rather than setting on a event like RACE?
2. Secondly I am not sure why I had to set isWon bool to true....in order to run through the while loop. When I put in the default value (false) into While it never ran through the statements. Just slips out. Could you please give some reasoning on this bizzare behaviour as well?
Your Run() method has a parameter, is it a Point type?
So I guess, in that case you do not use Randomizer to get value as the incrementor for each picturebox's X point.
4. I would like to know how we can implement Run() method as original, without parameters. And is it a must to have this initInitialize() method since Timer object is already added in the form...
Haven't seen this declaration in Type Writer application...
Abaf, on 30 July 2011 - 04:25 AM, said:
Another way would be using timer....
private void InitInstances() //It will run only once
Clock = new Timer();
Clock.Interval = 100;
Clock.Tick += new EventHandler(Clock_Tick);//will call Clock_Tick on each tick (of 100 ms)
private void Clock_Tick(object sender, EventArgs args)//call run mwthod on tick
for (int i = 0 ; i <= 3 ; i++)
if (Result) break;
pt[i] = doggy[i].MyPictureBox.Location;
Result = doggy[i].Run(pt[i]);
winner = i;
This post has been edited by Diaz: 04 October 2012 - 10:59 AM