0

I have an excel sheet that contains 50,000 rows, Now I have to update these using EF. but Without full-cycle complete, I can't send any success message to the user, and the web page shows "Processing....." and every other operation is stopped, when the operation is done after 10-15 min later, then the user can see the success message. Now I want to do: User can see progress, such as "1000/ 50000 data updated", "2000/ 50000 data updated", "50000/ 50000 data updated". and user can do other operation between the current operation.

I tried using Async, But I can't find out the exact result.

Technology: Asp.Net Core MVC 3.1 EF Core 3.1 SQL server 2017

Sraban75
  • 85
  • 9
  • Please do share what you tried with async and how it doesnt do what you expect it to do – Jawad Feb 19 '20 at 06:43

2 Answers2

0

The async and await keywords don't cause additional threads to be created.

So, It means if you want a job run in the background separately, you should use Threads nor async. foo more explanation about the difference of thread and async you can follow this Eric Lippert's answer.

But fortunately, there are exist some library that you can use for handling Background workers, such as Hangfire. They define themself as below:

An easy way to perform background processing in .NET and .NET Core applications. No Windows Service or separate process required. Backed by persistent storage. Open and free for commercial use.

and you said you want to display a progress bar to the user, that you can handle tracking progress by hangfire too.

good luck.

Hamed Moghadasi
  • 1,523
  • 2
  • 16
  • 34
0

Based on yoour description and scenario, if possible, you can try following approach to achieve it:

1) For long-running bulk update operation, you can create and use a background task to handle it.

For exampel, using a queue triggered task, user can create a queue message for each new bulk update operation, then task would be triggered and process data from excel file.

2) For displaying progress of bulk update operation to web client user, you can integrate ASP.NET Core SignalR real-time web functionality into web client application.

In background task, call hub method to push progress message to the connected SignalR web client user(s).

Fei Han
  • 26,415
  • 1
  • 30
  • 41