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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:58:46+00:00 2026-06-07T23:58:46+00:00

Context I have this function which synchronize a list of sites between a table

  • 0

Context

I have this function which synchronize a list of sites between a table and several remote IIS:

namespace Dashboard.Controllers
{
    public class SiteController : Controller
    {
        public ActionResult Synchronize()
        {
            SiteModel.synchronizeDBWithIIS();

            return Content("Cool.");
        }
    }
}

I want to call this function asynchronously when the dashboard is starting and running.

Questions

  • You advise me to do a $.get() (jQuery) or to use AsyncResult (ASP.NET)?

  • May be use Application_start() in Global.asax?

  • Furthermore, can I improve this controller for synchronization go faster?

  • 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-07T23:58:48+00:00Added an answer on June 7, 2026 at 11:58 pm

    None of the above. This is something that you shouldn’t be doing in an ASP.NET application at all. You may read the following article about the dangers of this: http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx

    This is something that should be done in a separate application. You could use the Windows task scheduler for example to run this application at regular intervals and it will take care of doing this lengthy operation.

    There’s nothing worse in an ASP.NET application than blocking a worker thread for a long time. The only possible acceptable solution to implement this in an ASP.NET application is to use I/O Completion Ports. Then you could use an AsyncController. But from what I can see your SiteModel.synchronizeDBWithIIS(); is a blocking method so it cannot be done.

    But if your SiteModel offered an asynchronous API to perform an I/O intensive task (not CPU intensive) here’s how it could be implemented:

    public class SiteController : AsyncController
    {
        public void SynchronizeAsync()
        {
            AsyncManager.OutstandingOperations.Increment();
    
            SiteModel.GetHeadlinesCompleted += (sender, e) =>
            {
                AsyncManager.OutstandingOperations.Decrement();
            };
    
            SiteModel.synchronizeDBWithIISAsync();
        }
    
        public ActionResult SynchronizeCompleted()
        {
            return Content("Cool.");
        }
    }
    

    Once you have done that whether you will invoke the Synchronize action using an AJAX call or a normal call it doesn’t really matter. What matters is that this action is now asynchronous and doesn’t block a worker thread. It delegates this to the underlying API which at the moment to perform lengthy I/O operations uses the BeginXXX, EndXXX methods on the Streams, Sockets, Database Connections, … It is important to understand that if your API doesn’t already implement this, you cannot just wrap a synchronous method in a new thread or an async delegate and execute it there. I mean you can, but you gain strictly nothing from doing that.

    Remark: don’t be fooled into thinking that this will make your operation faster. There’s no miracles for that. The operation will take exactly the same time as before. It’s just that during its execution you won’t be jeopardizing ASP.NET worker threads and your other requests will be executed faster.

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

Sidebar

Related Questions

I have this reduce function: protected void reduce(Text key, Iterable<SortedMapWritable> values, Context context) throws
I have a function which implement an interface. something like this: string IMyInterface.MyFunction() {
I have an onclick function which performs several tasks. In another JavaScript function I
So we have this SYS_CONTEXT function in Oracle, which takes two parameters, first a
I have a function which calls several other functions, e.g. sub do_work { send_mail();
I have this callback function setup: var contextMenu = []; var context = [
I have some code like this: var content = document.getElementById('myDivId'); function MyFunction() { alert(content.style.height);
this is what I have so far: <script> $(document).ready(function(){ $(.entry-content img:first).addClass('postimage'); }); </script> As
Context I have this piece of Java Code btn.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent
I have this var manager = context.ManagerInfoes.Select(m => m.Guid == managerGuid).First(); how can i

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.