Developer forum

Forum » Development » Scheduled task progress

Scheduled task progress

Karol Barkowski
Reply

Hello,

I have a working DW website that contains quite a lot of products. Now, from time to time I need to iterate those porducts and make sure that they are in sync with some external data sources.
So I've made a scheduled task for that and it works ok but the only problem that I have is tha it can take really long time to complete. I'm ok with the time since the amount of products is high so there's no way to do it quick but is there any way I could show a progress of a scheduled task that's running? I know upfront how many products I have so it would be perfect to show simething like "Products synced: 55 of 50000" or even simple percentage value showing how far we are and that there's actually some progress made.

Is it possible?

Also is there any way to cancel a scheduled task that's running?

Thanks in advance.


Replies

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Karol,

The Scheduled Task UI is not designed for this kind of feedback. If you need to execute and keep track of progress, I would suggest using the LogManager to log for every x iteration. Then you can vist the log for information on the progress. 

Something like

Dynamicweb.Logging.LogManager.System.GetLogger(LogCategory.Monitoring, "CustomStuff").Info($"{counter}/{total}");

Another approach could be your own aspx that refreshes at intervals, but this may be overkill.

As a thumb rule you cannot stop a running Scheduled Task process, other than recycling the ApplicationPool. If you need to, you should put a check into your iteration that sniffs at some value (request value, setting in a file or alike), and then break out of the iteration.

BR
Snedker

 

You must be logged in to post in the forum