You did not say what the problem was
~Andrew
On Aug 30, 2:24 pm, raz230 <[EMAIL PROTECTED]> wrote:
> I have a problem has occasionally happens in my program. The program
> is is a shipping system and has a scale connected to the PC with a
> serial cable.
>
> I use a background worker from inside a timer control to poll the
> scanner for it's weight and display it on the main form's window in a
> textbox control.
>
> The computer I develop on is a dual core machine. I'm not sure if
> this has any bearing but I can tell that I do not observe the problem
> at all in the development environment.
>
> I have this tick event on the main form:
>
> If My.Settings.UseScale = True Then
> Try
> BackgroundWorker1.RunWorkerAsync()
> Catch ex As Exception
> BackgroundWorker1.CancelAsync()
> End Try
> End If
>
> The dowork event of the background worker looks like this
>
> Private Sub BackgroundWorker1_DoWork(ByVal sender As
> System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
> Handles BackgroundWorker1.DoWork
>
> Dim worker As BackgroundWorker = CType(sender,
> BackgroundWorker)
> e.Result = GetScaleValue() 'returns a string
>
> End Sub
>
> And in the GetScaleValue function- the code that polls the scale looks
> like this
>
> Public Function GetScaleValue() as String
>
> Serial.Write("W") 'send "W" and read the reply
> txtDefaultWeight.Text = Serial.ReadExisting.ToString 'this is the
> reply
>
> If txtDefaultWeight.Text.Length > 2 Then 'clean up the reply
> With txtDefaultWeight
> .Text = .Text.Remove(0, 1)
> .Text = .Text.Remove(txtDefaultWeight.Text.Length - 1, 1)
> End With
> End If
>
> End Function
>
> Is this the correct way to handle this? I'm sure there's more than
> one way, but is what I have wrong or flawed?
>
> Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---