timer control ...executing function issue

2 posts, 0 answers
  1. Meenu
    Meenu avatar
    8 posts
    Member since:
    Mar 2013

    Posted 27 Aug 2013 Link to this post

    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

      
  2. Meenu
    Meenu avatar
    8 posts
    Member since:
    Mar 2013

    Posted 28 Aug 2013 Link to this post

    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
  3. DevCraft banner
Back to Top