Hi,
This might be more personal preference but i’d Like to know peoples ideas on why they’d do this problem one way or the other.
All of this is happening on a separate background thread, so you don’t have to worry about blocking the UI or anything.
In this thread I have 2 tasks to do:
1. has to be done every 0.5Seconds
2. Can vary between needing to be done once every 1 second or every 30 seconds.
The two options I see
VB Code:
Dim StartTime = Datetime.Now
Dim Interval as Double= (input)
While [Condotion]
‘Do task one
If (task1outcome =False)
Exit While
End if
If StartTime.Subtract(DateTime.Now) > Interval Then
‘Do task two
StartTime = Datetime.now
End if
Thread.Sleep(500)’ms
End While
‘—————— Option 2 ————
While [Condition]
‘Do task 2
Thread.Sleep(Interval)
End While
‘The above code would be Run in a task
While [Condition]
‘Do task 1
If (task1outcome = False) Then
Stop Task
Exit While
End If
Thread.Sleep (500) ‘ms
End While
Sorry for the bad Pseudo code, but this was semi bothering me and I’m on my phone.