Do you have any code examples similar to what i'm doing? This is what i have so far, but i'm unsure what to do with the Me.ListBox1.Items.Add(tmp & vbNewLine) bit.
Thanks for any advice/code.
Main Topics
Browse All TopicsHello.
I have this code and it works but i'm trying to output the results to a list box:
Private Sub BtnB17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnB17.Click
Dim t As Threading.Thread
t = New Threading.Thread(AddressOf
t.Start()
End Sub
Private Sub BackgroundProcessB17()
Dim p As Process = New Process 'This is the name of the process we want to execute
p.StartInfo.FileName = ("c:\psshut.bat")
p.StartInfo.UseShellExecut
p.StartInfo.RedirectStanda
p.StartInfo.CreateNoWindow
p.Start()
' read all the output
Dim SROutput As System.IO.StreamReader = p.StandardOutput
Dim tmp As String
Do While p.HasExited = False
tmp = SROutput.ReadLine
If tmp <> "" Then
Me.ListBox1.Items.Add(tmp & vbNewLine)
End If
Loop
p.Dispose()
End Sub
Although i am getting this exception:
Cross-thread operation not valid: Control 'ListBox1' accessed from a thread other than the thread it was created on
On this line:
Me.ListBox1.Items.Add(tmp & vbNewLine)
How can i get around this.
Thanks in advanced.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: DhaestPosted on 2008-11-17 at 02:53:37ID: 22974420
Perhaps you should take a look at this article: Updating the UI from a Secondary Thread en-us/maga zine/cc188 732.aspx tin_rogers /articles/ 126345.asp x
http://msdn.microsoft.com/
http://weblogs.asp.net/jus