I recently switched my code from using the windows.forms.timer to the systems.timer.timer and it has resulted in a multithreading error. I'm using the timer to trigger just one event so multithreading shouldn't be an issue. To give more detail I have implemented the timer at follows: At the top of the class I have:
Private Shared timr1sec As System.Timers.Timer
When the program loads (Private Sub Test_load):
timr1sec = New System.Timers.Timer(1000)
AddHandler timr1sec.Elapsed, AddressOf OnTimedEvent
In OnTimedEvent I call several subroutines, and write some data to the screen using a ListView object. VisualExpress throws the multithreading error on the last line of this code, which is in OnTimedEvent
Dim itm As New ListViewItem(str(0))
itm.SubItems.Add(str(1))
itm.SubItems.Add(str(2))
itm.SubItems.Add(str(3))
itm.SubItems.Add(str(4))
itm.SubItems.Add(str(5))
ListView1.Items.AddRange(New ListViewItem() {itm})
Any idea what it is about this new timer that's causing VisualExpress to say I'm multithreading?