c# - How resource heavy is a Timer? -


I'm running a timer like this:

  private zeros initializeTimer () {timer MyTimer = New Timer (); MyTimer.Interval = 3000; MyTimer.Enabled = true; MyTimer.Tick + = new event handler (TimerEvolutionProcessor); MyTimer.Start (); }   

This will speed up an event every third time. This event is not very heavy I think it is reading text from a file, comparing text length with text in a text box and replacing the box in text if there are more characters.

But is the resource heavy timer? And is it a bad idea to read the text from every third file (file is a log file in plain text).

"post-text" itemprop = "text">

A timer is fairly light, though it depends on the type of timer you are using. There is no possibility of a big deal every 3 seconds when a timer is fired, even if you are using a Windows form timer, make sure your tick event handler is not doing any important processing, like the UI Thread is in the thread (for example, check file length instead of "reading", etc.)

That is being said, to see changes in the log file, read the timer and re-read From to In addition to Ta is better to continue File inform you change immediately, it prevents you file read constantly.

Comments