Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3752454
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:14:38+00:00 2026-05-19T09:14:38+00:00

Working with BackGroundWorker in my WPF 3.5 application to make a long running process

  • 0

Working with BackGroundWorker in my WPF 3.5 application to make a long running process run on its own thread and when I run the code in debug mode in VS2010, the DoWork and the RunWorkerCompleted events do not seem to be firing.

My code is as follows:

Implements INotifyPropertyChanged  

Private WithEvents worker As System.ComponentModel.BackgroundWorker  

Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

Private Sub NotifyPropertyChanged(ByVal info As String)
  RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
End Sub

Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
  Dim worker = New System.ComponentModel.BackgroundWorker
  worker.WorkerReportsProgress = True
  worker.WorkerSupportsCancellation = True
  Dim str() = New String() {"IDA00005.dat", "Adelaide"}
  Try
    worker.RunWorkerAsync(str)
  Catch ex As Exception
    MsgBox(ex.Message)
  End Try
End Sub

Private Sub worker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles worker.DoWork
  Dim form_Helpder As New test_global
  Dim ds As DataSet = form_Helpder.getWeatherData(e.Argument(0), e.Argument(1))
  e.Result = ds
End Sub

Private Sub worker_Completed(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Handles worker.RunWorkerCompleted
  If e.Error IsNot Nothing Then
    MsgBox(e.Error.Message)
  Else
    ...
    NotifyPropertyChanged("lbl_minToday")
    ...
  End If
End Sub

I have setup breakpoints at runworkerasync and the line is called, not errors are catched but the sub is ended. I have breakpoints also setup on the DoWork and RunWorkerCompleted sub and after the Window_Loaded sub ends, nothing else is highlighted by the debugger, so I am only assuming that the Events are not being fired.

I have two questions, is there anything missing from my code that would make the events not fire, and is the use of breakpoints set on Event subs the correct way of debugging?

Any assistance that can be provided will be greatly appreciated.

Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:14:38+00:00Added an answer on May 19, 2026 at 9:14 am

    DoWork and worker_Completed are events. You have to register them to the worker’s event handlers for the worker to fire them.

    worker.DoWork += worker_DoWork
    worker.RunWorkerCompleted += worker_Completed
    

    Edit: In VB, it looks like the syntax is:

    AddHandler worker.DoWork, AddressOf worker_DoWork
    AddHandler worker.RunWorkerCompleted, AddressOf worker_Completed
    

    As for your second question, yes, the debugger will break if you set a breakpoint on the worker subroutine. DoWork runs on a background ThreadPool thread, while RunWorkerCompleted is raised and runs on the UI thread (which is what makes backgroundWorkers so useful.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code its not working btnUpload.TouchDown += delegate { BackgroundWorker bw = new BackgroundWorker();
I'm working with BackgroundWorker , I want the BackgroundWorker do the retrieval process of
I am working on a WPF application. I have a time consuming method that
I am working on a Winform Application. The Method is started by a BackgroundWorker
I want to hide the main window while the backgroundworker is working, but When
I'm using a BackGroundWorker to avoid UI freezing while working with a method which
I'm working on some code that calls a service. This service call could fail
I am working on a C# windows application. This application is mainly related to
I'm working on a WPF download manager which should support downloading multiple files at
I'm working on a WinForm project, using BackgroundWorker , for a data extraction procedure,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.