There is a program with a form and two timers.

Situation 1: One timer is triggered once a second and makes a request to the server for information. The accuracy of this timer is not very important. It is necessary to display visually on the form that a data update occurred or that a timer tick occurred. For example, with a blinking sign, it blinked and is not displayed until the next tick. I tried to do an animation by changing the color of some text on the label, with a delay through Thread.Sleep(300) which actually caused a problem (blinking of an element of an unstable frequency due to the fact that the call is shifting in time).

Situation 2:

 Dim aTimer As System.Timers.Timer ' Создаем таймер с интервалом в зависимости от настроек aTimer = New System.Timers.Timer(Me.delay) ' Биндим процедуру вызова таймером через определенные интервалы AddHandler aTimer.Elapsed, AddressOf OnTimedEvent aTimer.Enabled = True Private Sub OnTimedEvent(source As Object, e As ElapsedEventArgs) ' тут http вызовы с последующей записью в базу а также метод ' который отображал срабатывания тика таймера, что так же приводит к ' проблеме из ситуации №1 End Sub 

Tell me how best to solve this problem, that is, to display the timer tick visually without causing out of sync in the frequency of the procedure call that goes below the code.

    1 answer 1

    The easiest way is 2 timers.

    The 1st timer triggers the necessary actions, changes the color, for example, in Label , and activates the second timer.

    2nd timer after a specified interval changes the color of the Label back and off, before re-activation.

    In this case, the interval of the first timer must be greater than the interval of the second.

    The second option is to make your own control flasher with a timer inside and settings. Place it on the form and just pull this control with the application's main timer. The second option requires more code, but allows you to reuse the flasher where necessary.