Private Sub SMSPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles comPort.DataReceived
Dim str As String = ""
Dim temp As String = ""
If e.EventType = SerialData.Chars Then
SMSPort.DtrEnable = True
tempp = SMSPort.ReadExisting().Replace(">", "").Trim()
// here i want to add th split charcters
If tempp <> "" Then
objCon.GetConnection("Insert into tblAttended(Id,Status,Date,Time)values('" + tempp.ToString() + "','In','" + System.DateTime.Today.ToShortDateString() + "','" + DateTime.Now.ToShortTimeString() + "')")
ListView1.Items.Add(tempp) txtUniqueNumber.Text = tempp.Trim() ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
Control.CheckForIllegalCrossThreadCalls = False
You must be calling this method from delegate which send it to different thread and from different thread you cannot access the primary thread. what you should do is just update variables and access them from Primary thread.
I guess it may help you.
First, You have to declare one variable for every property your want to change at application level. so that u can access these variables in your primary thread as well as secondary thread.
Now, instead of updating the property directly, you have to update the property from secondary thread and access that variable in primary thread to update the desired property.
hope it helps,
mark as answer if helped..........
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)