Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Change labels and other objects when Backgroundworker is done.

Posted on 2008-11-04
9
Medium Priority
?
278 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:Hawkvalley1
  • 4
  • 3
  • 2
9 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 800 total points
ID: 22878600
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
 
LVL 9

Author Comment

by:Hawkvalley1
ID: 22878683
Hi emoreau, why yes I did. And yes I have read your article - we just worked on the progressbar earlier.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22878779
I think we would need to more code then to figure out what is wrong...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22878790
>>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
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22878855
if you try my sample, is it working?
0
 
LVL 9

Author Comment

by:Hawkvalley1
ID: 22878949
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
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22879022
I just retried my sample and this event is working. Do a quick comparison and you should find where the difference lies.
0
 
LVL 9

Author Comment

by:Hawkvalley1
ID: 22880384
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22881148
Lol...glad you figured it out.  =)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question