I am using a tick event within a form to trigger a timer (see other thread). The tick code for this timer is:
The class listens for this and then triggers the code below
However when i run it i get the following error message.
"An unhandled exception of type 'System.Threading.ThreadStateException' occurred in system.windows.forms.dll
Additional information: Could not instantiate ActiveX control '648a5600-2c6e-101b-82b6-000000000014' because the current thread is not in a single-threaded apartment."
As you can imagine, i wouldnt have a clue what this means!
Anybody got any ideas?
Visual Basic:
Dim c As CommClass
Dim t As New System.Threading.Timer(AddressOf c.Tick, Nothing, 0, 5000)
The class listens for this and then triggers the code below
Visual Basic:
Public Class CommClass
'Dim t As New System.Threading.Timer(AddressOf Tick, Nothing, 0, 5000)
Public Shared Sub Tick(ByVal state As Object)
Dim comm2 As New AxMSCommLib.AxMSComm
comm2.InputLen = 5000
comm2.OutBufferSize = 5000
comm2.InBufferSize = 5000
comm2.CommPort = 1
comm2.InputMode = MSCommLib.InputModeConstants.comInputModeText
comm2.Handshaking = MSCommLib.HandshakeConstants.comNone
comm2.RThreshold = 1
comm2.SThreshold = 0
comm2.Settings = "9600,n,8,1"
comm2.PortOpen = True 'Opens port
comm2.DTREnable = True 'Prepares port to receive data
'comm2.RTSEnable = True 'This prepares the connection to send data
MessageBox.Show("test")
strNewRecFromBuffer = comm2.Input()
ReadBuffer()
End Sub
End Class
However when i run it i get the following error message.
"An unhandled exception of type 'System.Threading.ThreadStateException' occurred in system.windows.forms.dll
Additional information: Could not instantiate ActiveX control '648a5600-2c6e-101b-82b6-000000000014' because the current thread is not in a single-threaded apartment."
As you can imagine, i wouldnt have a clue what this means!
Anybody got any ideas?