3 Replies - 407 Views - Last Post: 25 December 2019 - 03:12 PM Rate Topic: -----

#1 Nicomendox   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 05-March 16

While timer working, why form can not move properly ?

Posted 25 December 2019 - 01:45 PM

I write a simple code with Timer. but when I start timer and then when I try to move form with mouse dawn or when I try to click a Button response with delayed.

Public Class Form3
    Dim _RGB As Integer
    Dim renk As Color
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim hiz As Double
        hiz = -0.4

        For i = 256 To 0 Step hiz
            _RGB = RGB(i, 0, 0) 'VScrollBar1.Value, 0, 0) ', VScrollBar2.Value, VScrollBar3.Value)
            renk = ColorTranslator.FromOle(_RGB)
            'RectangleShape1.FillColor = renk
            PictureBox1.BackColor = renk
            PictureBox1.Refresh()
        Next i

        For i = 256 To 0 Step hiz
            _RGB = RGB(0, i, 0) 'VScrollBar1.Value, 0, 0) ', VScrollBar2.Value, VScrollBar3.Value)
            renk = ColorTranslator.FromOle(_RGB)
            'RectangleShape1.FillColor = renk
            PictureBox2.BackColor = renk
            PictureBox2.Refresh()
        Next i

        For i = 256 To 0 Step hiz
            _RGB = RGB(0, 0, i) 'VScrollBar1.Value, 0, 0) ', VScrollBar2.Value, VScrollBar3.Value)
            renk = ColorTranslator.FromOle(_RGB)
            'RectangleShape1.FillColor = renk
            PictureBox3.BackColor = renk
            PictureBox3.Refresh()
        Next i



    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If Timer1.Enabled = False Then
            Timer1.Start()
        Else
            Timer1.Stop()
        End If
    End Sub
End Class


Is This A Good Question/Topic? 0
  • +

Replies To: While timer working, why form can not move properly ?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15477
  • View blog
  • Posts: 62,007
  • Joined: 12-June 08

Re: While timer working, why form can not move properly ?

Posted 25 December 2019 - 02:00 PM

When the timer event is happening it locks up the main thread..including UI updates.
Was This Post Helpful? 0
  • +
  • -

#3 Nicomendox   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 05-March 16

Re: While timer working, why form can not move properly ?

Posted 25 December 2019 - 02:24 PM

View Postmodi123_1, on 25 December 2019 - 02:00 PM, said:

When the timer event is happening it locks up the main thread..including UI updates.


thanks for concern..

And then.. how can I solve this problem ?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15477
  • View blog
  • Posts: 62,007
  • Joined: 12-June 08

Re: While timer working, why form can not move properly ?

Posted 25 December 2019 - 03:12 PM

I don't know what you are attempting to do in the function.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1