Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I tick the timer when the for loop is completed? I don't want to run the timer every X minute, I want to run the timer when the button is clicked and then just tick the timer again when the for loop is completed..

VB.NET
 For Each row As DataRow In MTProcessTable.Rows
  Try
            If checkKeyHelp(process.datain) Then
                msg = msgTable.Rows(1)(1).ToString()
                MsgBox(msg)
                writeMsg("1 MO help at ")

            ElseIf checkKeyInfo(process.datain) Then
                msg = msgTable.Rows(4)(1).ToString()
                MsgBox(msg)
                writeMsg("1 MO INFO at ")
            Else

                MOTable = selectMO(process.mo, process.mt)
                moRowNb = MOTable.Rows.Count()
                MO = New MO_class
                If moRowNb <> 0 Then
                    MOrow = MOTable.Rows(0)
                    MO.newuser = MOrow("newuser")
                    MO.sim_id = MOrow("sim_id")
                End If
       Catch ex As Exception
            logFile("executeTimer ----" & ex.Message)
            updateProcessed(process.id, ex.Message)
        Finally
            updateProcessed(process.id, msg)
        End Try
 Next row

Private Sub start_btn_Click(sender As System.Object, e As System.EventArgs) Handles start_btn.Click
    Timer1.Enabled = True
    tm.StartTimer()
End Sub


when the timer starts, i'm filling a datatable and i'm executing some action on every row in the for loop and when the for loop is finished the function should start all over again and datatable is refilled with a different number of rows...so i can't know the time needed for the function to be completed because everytime i have different number of rows that's why i just need to tick the timer once the function has executed all the rows in the datatable

any help?
Posted
Updated 5-Sep-13 3:58am
v2
Comments
ZurdoDev 5-Sep-13 9:00am    
Perhaps you should not use a timer?
[no name] 5-Sep-13 9:06am    
Well I would think that you would rethink what you are doing so that it makes some sort of sense.
Jocelyne El Khoury 5-Sep-13 9:09am    
well actually the task i was given is to use a timer :/

1 solution

OK, weird. You're kind of abusing the timer, but whatever.

It's simple. Disable the timer before the for/next loop and Enable it again after the loop.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900