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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:19:50+00:00 2026-06-11T11:19:50+00:00

There are couple of methods in a class that perform some lengthy operation and

  • 0

There are couple of methods in a class that perform some lengthy operation and should periodically report progress to the caller, e.g. to display on presentation layer, log in file, etc.

I’ve used following solution in the past, but I’m concerned if that is the preferred way to do it:

I have callback delegate defined like that:

public delegate bool ProgressCallback(double percentCompleted, object arg);

Then my “worker” method is like that:

public bool DoSomething(bool firstArg, int anotherArg, ProgressCallback progressCallback, object callbackArg);

I invoke progressCallback after each iteration of a long process, and if it returns false, that means the operation should be aborted.

Note that the process has to be synchronous, there is no need for asynchronous implementation.

I just see repeating this technique over and over in my code, so I’m concerned whether this is a recommended pattern. Is this how you would implement such thing? Should I use events instead, or does such simple implementation seem ok for you?

  • 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-11T11:19:51+00:00Added an answer on June 11, 2026 at 11:19 am

    That is the right way to do it!

    But to save you some time (and code) probably, look at the BackgroundWorker

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

Sidebar

Related Questions

So I had a couple of methods in my main class that used a
I have an abstract java class that implements a couple of its methods, but
I have a class with a couple of methods that convert from one generic
I have a Python class that raises NotImplementedError for a couple of methods and
During startup of my WinForms application I'm noting that there are a couple of
I have a couple of standard ASP.NET web methods that I'm calling from javascript
I've got a class that is essentially mutable, but allows for some persistent-like operations.
I've been using a couple of methods on a simple class, which have worked
There are couple of ways to access azure storage services. And I wanted to
There are couple of JSON frameworks. JSONKit , SBJSON , Native JSON and other.

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.