Solved

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

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now