Link to home
Start Free TrialLog in
Avatar of cmdolcet
cmdolcetFlag for United States of America

asked on

How to enable a timer tick event in a Data Received Handler Event?

I have a the following code: that it executes howeverI can never get my timer tick event to fire after the condition is met in the indata.length is met????

frmMain()
SetupSerialAutomationDataReceivedCOMPort()
End Sub

Public Sub SetupSerialAutomationDataReceivedCOMPort()
       Dim mySerialPort As New SerialPort("COM1")
        mySerialPort.BaudRate = 9600
        mySerialPort.Parity = Parity.None
        mySerialPort.StopBits = StopBits.One
        mySerialPort.DataBits = 8
        mySerialPort.Handshake = Handshake.None
        AddHandler mySerialPort.DataReceived, AddressOf DataReceivedHandler
mySerialPort.Open()
End Sub

  Private Sub DataReceivedHandler(
                        sender As Object,
                        e As SerialDataReceivedEventArgs)
        Dim sp As SerialPort = CType(sender, SerialPort)
        Dim indata As String = sp.ReadExisting()
   
if indata.length=21 then
tmrPartfileLoaded.start()
end if

    End Sub
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Does the condition evaluate to true? How do you know timer event is not firing? Do you have a breakpoint in there?
ASKER CERTIFIED SOLUTION
Avatar of cmdolcet
cmdolcet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Select your comment as the answer.
Avatar of cmdolcet

ASKER

I found the solution myself by using the invoke method.