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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:14:18+00:00 2026-05-29T12:14:18+00:00

Sorry if this is quite a long question, i need some advice on what

  • 0

Sorry if this is quite a long question, i need some advice on what people consider to be the best method (as there are a few).

At the moment, my project has a method

do_job(jobid,userid)

This method take a minute or two, and then redirects to another page.

This has been rewritten so that it now runs in the background and redirects to another page whilst the thread which do_job is on continues. – This works fine.

In a button_click event in a default.aspx page :

Dim d as New do_job_delegate(AddressOf do_job)
d.BeginInvoke(jobid,userid, New AsyncCallback(AddressOf Callback),d)
Response.redirect("results.aspx")

Which relates to

Delegate Sub do_job_delegate(Byval jobid as integer, Byval userid as integer)

Public Sub do_job(Byval jobid as integer, Byval userid as integer)
     ' Do something for several seconds
End Sub

Public Sub Callback(Byval ar As IAsyncResult)
    ar.AsyncState.EndInvoke(ar)
End Sub

This basically does what i want, a user can carry on doing things on the site and the do_job method runs in the background and completes its tasks successfully.

However, i’ve now added to this do_job method, and there are several small tasks, each taking 30 or so seconds within do_job, and they could/should be made to run parallel.
e.g

Public Sub do_job(Byval jobid as integer, Byval userid as integer)
     loop through between 1 or more (up to roughly 10 items)
         'process that takes about 30 seconds
     end loop
End Sub

So what i want to happen is – the longest time that do_job takes is the longest time of the longest job (30 seconds), rather than – 30 seconds x number of jobs = time it takes at the moment.

As i’m already using a delegate to detact the process from the ui, can anyone provide any advice/best practice on how i should rearrange my do_job method so that it can handle concurrent tasks to further boost the overall speed.

Thanks!

  • 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-29T12:14:20+00:00Added an answer on May 29, 2026 at 12:14 pm

    I would recommend that before you spend a bunch of time on this that you consider moving the work to a separate service rather than running it inline on your web server.

    Just throw a record into a db table and have the service watch it.

    Here is an article from Phil Haack explaining why you shouldn’t mess with threads on your web server.

    http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx

    As far as executing the tasks in parallel, look at the .net 4.0 Parallel libraries. They make this kind of thing super easy.

    http://msdn.microsoft.com/en-us/library/dd460717.aspx

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

Sidebar

Related Questions

I'm sorry this is a very long question. I'm looking for help from people
Sorry for this simple question, but I can't solve it... There is an example:
I know this is quite a vague question -- sorry about that. If I
First and foremost, I'm so sorry about how long this question is and appreciate
sorry if this quite a easy question, but i cant find any thread the
Sorry for this long question, it is flagged wiki since I'm asking for something
Sorry if this has been asked before - there's a question with a similar
I'm refactoring some code. Right now there are quite a few places with functions
Sorry if this is quite noobish to you, but I'm just starting out to
Sorry if this is a repost but I couldn't quite search for it because

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.