Reputation:
I have a timer in vb.net and it's interval is 1000ms ,. i have placed in it's timer_tick event a code that will print screen the screen and save it to a database.
The problem is when i click outside of the form, or loosing the focus of the mouse to the form containing that timer/printscreen, the timer stops. As a result the printscreen also stops.
here are it's properties:
generate member = true
interval = 1000
modifiers = friend
I will appreciate any reply or tip regarding this problem ,. thank you.,
Upvotes: 0
Views: 4716
Reputation: 51141
A simple test creating a form with a Timer
with
Interval = 1000,
Enabled = True
and the following code in the form
Dim i As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Debug.WriteLine(i)
i += 1
End Sub
continued to Tick
(and produce output) regardless of whether or not the form had the focus.
Are you sure that you are not calling Stop()
or setting Enabled
to False
anywhere in your code?
I'd recommend putting a breakpoint anywhere you call Stop()
or change Enabled
; then you can see if these lines are being executed when the form loses focus.
Upvotes: 1