I am having a pre defined list of machines and a constant duration in minutes.
Each machine is started mechanically when it does my program receives an input from the machine and I am storing the machine id, start time , added value of duration with start time as end time, duration and status of the machine in sql server database.
in the win forms screen using vb .net and listview i am displaying the data from the table and refreshing it through a timer. The timer interval is one second. the query is also calculating the elapsed time and displaying in the listview. and from UI when duration and elapsed minutes reaches equal program send a signal to update the database .now is it wise to use timer to this activity or threading.task which is more efficient. any help is greatly appriciated.
for ref the code with query is
Sub loadfromtable()
Try
ListView1.Items.Clear()
Dim qry As String = "select *,DATEDIFF(second,starttime,cast(GETDATE()AS time))/60 as etime from tblconsole where status='A' AND DATEDIFF(second,starttime,cast(GETDATE()AS time))>0"
'old qry --"select *,'' as [etime] from tblconsole where status='A'"
Using db As New sqlDataclass
Dim dt As DataTable = db.bindData(qry)
If Not dt Is Nothing AndAlso dt.Rows.Count > 0 Then
For Each r As DataRow In dt.Rows
Dim itm As New ListViewItem(r(0).ToString)
itm.SubItems.Add(r(1).ToString())
itm.SubItems.Add(r(2).ToString())
itm.SubItems.Add(r(4))
itm.SubItems.Add(r(3))
itm.SubItems.Add(r("etime"))
ListView1.Items.Insert(0, itm)
Next
End If
End Using
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub