I have a window form that receives data from a scale through a serial port. Since I need an operator to be able to cancel the process, I am doing the process of receiving data in the second thread.
The data collection process receives several readings from the scale one at a time. The form has a label that should be updated with information related to each reading.
I am calling a method to get data from a scale using this code.
Dim ad As New readALine(AddressOf thisScale.readALine)
Dim ac As New AsyncCallback(AddressOf Me.GetDataCallback)
Dim iar As IAsyncResult = ad.BeginInvoke("", ac, ad)
The delegate for the readALine method is defined in the user interface code.
Delegate Function readALine(ByVal toSend As String) As String
GetDataCallback Method:
Private Sub GetDataCallback(ByVal ia As IAsyncResult)
.
.
.
lblInstructions.Text = _thisMeasure.dt.Rows(_currRow - 1).Item("cnt") & ":"
lblInstructions.Refresh()
.
.
.
End Sub
I get an exception in the lblInstructions.Text = statement.
, GetDataCallback , , . , , , BackgroundWorker , , .
VS2003 VS2008.
.
,
Dave