我正在编写一个涉及RFID和RFID的应用程序。条码扫描仪。我正在尝试为RFID扫描仪创建一个类。继续得到这个&%#$ *错误。
以下是相关代码:
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
...
我很难过。如果我拿出Dispatcher声明,我会收到“Me.Dispatcher不是成员”错误。
但是,我(无耻地)从制造商的演示应用程序中获取代码&它使用相同的timer_Elapsed(...)代码 - 项目中没有Dispatcher声明 - 运行得很好。
有什么想法吗?