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 8750703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:54:47+00:00 2026-06-13T12:54:47+00:00

I have a BackgroundWorker that calls a method that calls a method… and somewhere

  • 0

I have a BackgroundWorker that calls a method that calls a method… and somewhere along the line I check for CancellationPending and want to exit the BackgroundWorker.

Is there a way to do that directly from that deeply nested method or does it have to return to its caller, which in turn will return to its caller…?

  • 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-06-13T12:54:48+00:00Added an answer on June 13, 2026 at 12:54 pm

    There is nothing special about the fact that you’re using a BackgroundWorker – think about this in the same terms as you would just dealing with deeply nested method calls.

    In other words, no, there’s no (non-horrible) way I can think of to do that directly.

    The cleanest way I can think of is to simply check for CancellationPending immediately after you return from each nested method, at every level (and if true, return).

    Throwing a specific exception and catching same specific exception type at the top level would get you out quickly but isn’t exactly best practice (which is, don’t use exceptions anything non-exceptional, like normal flow control).

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

Sidebar

Related Questions

I have a BackgroundWorker that calls a method in a class. The method is
I have a backgroundworker which calls a method in the DoWork event. this method
I have a backgroundworker that runs a single process. I want to be able
I have a WCF service method that I want to perform some action asynchronously
In a WinForm application that calls a third-party command line tool, there may be
I have a small WinForms app that utilizes a BackgroundWorker object to perform a
I have a WPF ListView that I am trying to filter within a BackgroundWorker.
I have a timer tick that I would like to kick off my backgroundworker
I have a background worker that stops after 100 iterations. Like this: BackgroundWorker bgWorker
I am using a backgroundworker that can have n instances. Problem is the DoWork

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.