This is a migrated thread and some comments may be shown as answers.

timer control ...executing function issue

1 Answer 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Meenu
Top achievements
Rank 1
Meenu asked on 27 Aug 2013, 04:09 PM
Advance thanks to all...

I am using a timer control for calling a function (lastposition()) in each 20 seconds.Now the problem is first time there is no issue.Second time function is executing two times and the third time function is executing 3 times like that it is increasing.I dont understand what logic is missing in my code.

after 20 second lastposition function is executing 1 time
after 40 second lastposition function is executing 2 time
after 60 second lastposition function is executing 3 time
after 80 second lastposition function is executing 4 time.......

Like this ...Can anybdy check my below code and tell me what mistake in this?
Partial Public Class MainPage
    Inherits UserControl
    Dim _timerRealTime As New Storyboard()




Private
Sub ChkRealTime_Checked(sender As Object, e As RoutedEventArgs) Handles ChkRealTime.Checked
     _timerRealTime.Duration = TimeSpan.FromMilliseconds(1)
     AddHandler _timerRealTime.Completed, AddressOf Me._timerRealtime_Completed
     _timerRealTime.Begin()
 End Sub
 
 Private Sub _timerRealtime_Completed(sender As Object, e As EventArgs)
     LastPosition()
     _timerRealTime.Duration = TimeSpan.FromSeconds(20)
     _timerRealTime.Begin()
 End Sub
 
 Private Sub LastPosition()
     lastposdate = ""
     DoorOpenClose = "NO"
     'select Max date
     Dim Proxy1 As ComboLoadClient = New ComboLoadClient()
     AddHandler Proxy1.SelectmaxdateCompleted, AddressOf LastPositionRunning
     Proxy1.SelectmaxdateAsync(" WHERE       ([Group].GroupName = '" & TxtUsername.Text & "' )")
 End Sub

  

1 Answer, 1 is accepted

Sort by
0
Meenu
Top achievements
Rank 1
answered on 28 Aug 2013, 05:14 AM
I found  the problem.But could not solve the issue

When repeating the execution when I changing the selection  in the following combo.After each selection change again timer control is
calling the handler _timerRealtime_Completed

Help pls

 
Private Sub Cmbn_SelectionChanged(sender As Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles Cmbn.SelectionChanged
 
        'realtime code added
        If ChkRealTime.IsChecked = True Then
            ChkRealTime.IsChecked = False
            ChkRealTime.IsChecked = True
            Exit Sub
        End If
Tags
General Discussions
Asked by
Meenu
Top achievements
Rank 1
Answers by
Meenu
Top achievements
Rank 1
Share this question
or