.net - Eventhandler for serial port data receiving work only in debug mode -


it's quite strange. eventhandlers serial port seem working in debug mode. problem is, @ hardware side, rx , tx pins connected, means share same data line. in case, there 2 datareceived events triggered after every send. first 1 command itself, , second answer need. here code part:

private sub mspserialport_datareceived(byval sender object, _                                        byval e serialdatareceivedeventargs) _                                  handles mspserialport.datareceived     'handles serial data received events     dim inum integer = mspserialport.bytestoread     updateformdelegate1 = new updateformdelegate(addressof updatedisplay)      if inum > 0         redim mbreceivebuffer(inum - 1)         mspserialport.read(mbreceivebuffer, 0, inum)          if inum > 1             me.invoke(updateformdelegate1)         end if     end if  end sub 

the if-condition "inum > 1" intended neglect first received byte, command itself. works fine in debug mode, once program run in normal mode, received bytes in second event won't displayed. updatedisplay function shown below:

private sub updatedisplay()     'display received data     msreceivebufferstring = ""     = 0 ubound(mbreceivebuffer)         msreceivebufferstring &= (mbreceivebuffer(i).tostring("x2") & " ")     next      select case mbtestidflag         case gbtest_id_02      'sw-id             txtswid.text = msreceivebufferstring         case gbtest_id_2f      'trim value             txttrim.text = msreceivebufferstring         case else             'do nothing     end select  end sub 

does have ideas why doesn't work? because of delegate function, or eventhandler, or sth else? many in advance!


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -