Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core 2.1 Reporting progress of long task

I am in the midst of re-writing a very old VB legacy application into a browser based C# ASP.Net application using Core 2.1 and Entity Framework back-ended to SQL server.

Several of the functions are long-running tasks. One example is an import of an address gazetteer CSV file. The files are typically 50-100Mb in size and need parsing. I have written an uploader and import function, which runs in around 15 minutes - most of that is database write-time.

I am trying to find a way to run the import process so that it can report back progress to the client browser, ideally by changing the menu option to a progress bar until the task is done - since the _layout.cshtml is on every page, it would let any user know the task is running and when it will finish.

I've looked at IHostedServices and the BackgroundService functions, but I cannot find any examples that match what I'm trying to do. I've seen an article around MVC5 that used SignalR & Knockout (which I'm less familiar with) but it doesn't use the Core 2+ or the newer service functions.

Can anyone point me to a good .Net Core > 2.0 example of something like this?

Thanks in advance.

like image 418
Anthony Hunt Avatar asked Oct 16 '22 15:10

Anthony Hunt


1 Answers

For a long running process, you could use widely used Hangfire

Progress tracking via SignalR is described in the documentation : http://docs.hangfire.io/en/latest/background-processing/tracking-progress.html

It is compatible with .Net Core 2.1.

like image 163
greyxit Avatar answered Nov 09 '22 13:11

greyxit