-2

I use the following command to print adb output on textbox.text

Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork
    TextBoxSamLog.AppendText(Environment.NewLine & Adb.ExecuteAdbCommand(Adb.FormAdbCommand("sideload", TextBoxsideload.Text)))
End Sub

does the job, but does not print the output and gets an error

How can we print the result on the textbox in the backgroundworker?

ILYA20
  • 31
  • 2
  • 10

1 Answers1

1

The BackgroundWorker has built-in functionality to allow you to access the UI thread, which is the whole point of its existence.

If you want to update the UI after the background work is completed then you handle the RunWorkerCompleted event and pass the data via the e.Result property. If you want to update the UI during the background work then you call the ReportProgress method, pass the data via the userState parameter and handle the ProgressChanged event. Both those events are raised on the UI thread.

Click here for more information.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46