[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

Background worker

I have a background worker in my code, what I am trying to do is check at a scheduled time if the background worker is dead restart it
0
mannsingh3
Asked:
mannsingh3
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Why would your background worker be "dead"?...what are you doing in it?
0
 
jhshuklaCommented:
Do you have the code that runs at scheduled time? If you have that all you need is to check IsBusy flag on the bg worker.

If you need to restart the worker under specific conditions (e.g. stopped prematurely or threw exception), then you will need a lot more work.
0
 
mannsingh3Author Commented:
can you shed some light what extra needs to be done if background worker needs to be started if stopped prematurely or threw an exception.
0
 
jhshuklaCommented:
1. Register for RunWorkerCompleted event.
2. When the worker stops (work completed, gracefully cancelled, or terminated due to exception), the method is invoked. Check the Error property on RunWorkerCompletedEventArgs.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now