I'm writing an application that involves both RFID & barcode scanners. I'm trying to create a class for the RFID scanner & keep getting this &%#$* error.
Here's the relevant code:
Private Dispatcher As Dispatcher
Private Delegate Sub TimerDispatcherDelegate()
...
'[Constructor]
'Start timer
timer = New System.Timers.Timer()
AddHandler timer.Elapsed, AddressOf timer_Elapsed
timer.Interval = 1000
timer.Enabled = True
End If
End Sub
Private Sub timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
'Delegate handler for timer events
***NEXT LINE THROWS THE ERROR- Me.Dispatcher is not set to an instance of an object***
Me.Dispatcher.Invoke(Windows.Threading.DispatcherPriority.Normal, New TimerDispatcherDelegate(AddressOf timer_WorkItem))
End Sub
Private Sub timer_WorkItem()
'Populate reader struct
ReaderState.Name = ReaderName
ReaderState.CurrentState = SmartCard.SCARD_STATE_UNAWARE
...
I'm stumped. If I take out the Dispatcher declaration, I get a "Me.Dispatcher is not a member" error.
However, I'm (shamelessly) pinching code from a manufacturer's demo application & it uses the same timer_Elapsed(...) code- with no Dispatcher declaration in the project- and runs just fine.
Any thoughts?