Solved

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

Posted on 2013-01-21
4
472 Views
Last Modified: 2013-01-27
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
0
Comment
Question by:cmdolcet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38801826
Does the condition evaluate to true? How do you know timer event is not firing? Do you have a breakpoint in there?
0
 

Accepted Solution

by:
cmdolcet earned 0 total points
ID: 38805551
Yes it does. I did figure it out thought. I used an Invoke and a timer .start() to trigger the timer.

me.Invoke(New MethodInvoker(Addressof me. timer.start))

How can I close this now?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38805563
Select your comment as the answer.
0
 

Author Closing Comment

by:cmdolcet
ID: 38823791
I found the solution myself by using the invoke method.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question