|
-
Aug 5th, 2012, 01:27 PM
#1
Thread Starter
Addicted Member
[RESOLVED] VB 2010: Cross-thread problem with Progress Bar
Alright so I finished my first program and I'm working on my second. I copied over a bunch of stuff and now the only problem I am having is this error with my progress bar.
"Cross-thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on."
I've fixed this before, but I can't quite remember. Here is the code it is being used by-
Code:
Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
ProgressBar1.Value = Convert.ToInt32(100 * P / 2)
End Sub
-
Aug 5th, 2012, 02:04 PM
#2
Re: VB 2010: Cross-thread problem with Progress Bar
Invoke the UI thread to access the progressbar properties.
vb Code:
ProgressBar1.Invoke(Sub() ProgressBar1.Value = Convert.ToInt32(100 * P / 2))
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
-
Aug 5th, 2012, 02:24 PM
#3
Thread Starter
Addicted Member
Re: VB 2010: Cross-thread problem with Progress Bar
Thanks! Although, I found the problem once I read back through my code. The report progress was set to the wrong progress change.
-
Aug 5th, 2012, 02:28 PM
#4
Re: [RESOLVED] VB 2010: Cross-thread problem with Progress Bar
The cross thread issue has more to do with threads trying to take action on threads that aren't their own.
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
-
Aug 5th, 2012, 02:52 PM
#5
Thread Starter
Addicted Member
Re: [RESOLVED] VB 2010: Cross-thread problem with Progress Bar
That really did help though, on a totally different part of my program xD Thanks.
-
Aug 5th, 2012, 03:03 PM
#6
Re: [RESOLVED] VB 2010: Cross-thread problem with Progress Bar
No problem, as long as you've got things figured out
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|