Skip to content

Commit

Permalink
Replace Delegate with Threading.Thread
Browse files Browse the repository at this point in the history
This seems to work much better. I'm getting both the PLM outgoing
message and the incoming ACKs now, which I wasn't before.
  • Loading branch information
ocdtrekkie committed Nov 25, 2015
1 parent 2536d1d commit 9d9aeec
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions modInsteon.vb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@

Private Sub SerialPLM_DataReceived(sender As Object, e As IO.Ports.SerialDataReceivedEventArgs)
' this is the serial port data received event on a secondary thread
Dim handler As New mySerialDelegate(AddressOf PLM)
Dim PLMThread As New Threading.Thread(AddressOf PLM)

Do Until SerialPLM.BytesToRead = 0
x(x_LastWrite + 1) = SerialPLM.ReadByte
Expand All @@ -189,12 +189,9 @@
If x_LastWrite > 1000 Then x_LastWrite = 1
Loop

' invoke delegate
handler()
PLMThread.Start()
End Sub

Public Delegate Sub mySerialDelegate()

Public Sub PLM()
' This routine handles the serial data on the primary thread
Dim i As Short
Expand Down

0 comments on commit 9d9aeec

Please sign in to comment.