Solved

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

Posted on 2013-01-21
4
461 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
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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