Change labels and other objects when Backgroundworker is done.

Hi all.

Running a BGW - when it starts a change a label to "Running Task," when the BGW is done I want to change the text to "Done with task." I assumed this could be done in the BGW_RunWorkerCompleted(), but it is not working andOr I am wrong. Thanks for the correction in advance...
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        If Not (e.Error Is Nothing) Then
            MsgBox(e.Error.Message)
        ElseIf e.Cancelled Then
            lblResult.Text = "Cancelled"
        Else
            lblResult.Text = "Done"
        End If
        SaveToolStripMenuItem.Enabled = True
        ProgressBar1.Value = 0
    End Sub

Open in new window

LVL 9
Hawkvalley1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
It really should work. Have you set the WorkerReportsProgress property to True? Have a look at http://www.emoreau.com/Entries/Articles/2006/12/The-BackgroundWorker-component.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hawkvalley1Author Commented:
Hi emoreau, why yes I did. And yes I have read your article - we just worked on the progressbar earlier.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
I think we would need to more code then to figure out what is wrong...
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Éric MoreauSenior .Net ConsultantCommented:
>>we just worked on the progressbar earlier

I don't look at the names when I post comments.

Is it the BackgroundWorker1 instance that you start or are you starting a new instance?

Can you show more code?
0
Éric MoreauSenior .Net ConsultantCommented:
if you try my sample, is it working?
0
Hawkvalley1Author Commented:
Do I need to make the BGW a new instance, I was only needing this operation once and then the form closes? I am just using the control I dropped onto the form.
0
Éric MoreauSenior .Net ConsultantCommented:
I just retried my sample and this event is working. Do a quick comparison and you should find where the difference lies.
0
Hawkvalley1Author Commented:
Ok I see, don't deviate from the plan Stan... sometimes it is the littlest darn things that mess it all up - all better in code land...
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Lol...glad you figured it out.  =)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.