Razvan Ghena Razvan Ghena -4 years ago 80
C# Question

C# timer stop after some number of ticks automatically

How to stop a timer after some numbers of ticks or after, let's say, 3-4 seconds?

So I start a timer and I want after 10 ticks or after 2-3 seconds to stop automatically.


Answer Source

You can keep a counter like

 int counter = 0;

then in every tick you increment it. After your limit you can stop timer then. Do this in your tick event

 if(counter ==10)  //or whatever your limit is
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download