1

I have an app that launches a long update on the backend (Dynamics 365 in this case). I want to launch it in the background while the user can continue doing things.

The problem is that while this task is running, the other pages don't load when I click on them. Maybe is the usual behavior.

Tried with Task.Run() HostingEnvironment.QueueBackgroundWorkItem() and the result is the same.

This is how my controller looks like:


        public ActionResult ConfirmCurrentMonthMeetings() {

            //Task.Factory.StartNew(() => QueryHelper.MarkReadOnlyCurrentMonthMeetings(guide.Id, svc));
            HostingEnvironment.QueueBackgroundWorkItem(clt => QueryHelper.MarkReadOnlyCurrentMonthMeetings(guide.Id, svc));

            ViewBag.ConfirmingMeetingsMessage = "Meetings being confirmed on the background. This action might take a few minutes";

            PrepareMainScreen();
            return View("MainScreen");
        }

  • You may try something like this: https://stackoverflow.com/questions/49813628/run-a-background-task-from-a-controller-action-in-asp-net-core there are other similar questions available as well. – Matt U Sep 24 '21 at 17:46
  • I saw that already and the problem is another one. I figured it out already. Thanks – Luis Gómez Ruiz Sep 24 '21 at 22:27

1 Answers1

0

Apparently the variable svc that I use to perform the queries to the CRM is a shared resource and cannot be used while it's in use. I defined a second one and worked fine.