Does SerialPort use polling internally?

Viewed 39

I have no idea how it could work differently, but I would like to ask anyway:

To read data from a serial comm port, I have always used polling.

First, I opened the port by getting a file handle, then I use a timer and read data from the file handle like this:

Private Function pReadComm32() As String

    Dim RetBytes As Long
    Dim i As Integer
    Dim ReadStr As String
    Dim bRead(256) As Byte
    Dim RetVal As Long
    RetVal = ReadFile(m_lTextFileHandle, bRead(0), 256, RetBytes, 0)
    ReadStr = ""
    If (RetBytes > 0) Then  
    For i = 0 To RetBytes - 1
        ReadStr = ReadStr & VBA.Chr(bRead(i))
    Next i

    pReadComm32 = ReadStr

End Function

Now when I port my project from VB6 to VB.NET, I would like to use the SerialPort component instead.

It provides the OnDataReceived events.

I would like to know how this component works internally. Does it do the very same under the hood as my code does and also uses polling?

This is a question out of interest, not a real problem.

Thank you!

0 Answers
Related