Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Fix timeInterval in BackgroundServiceTask - #425

support00d36d94c733
diff --git a/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs b/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs
index 8c01162e1..c6a7ea8c6 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/BackgroundServiceTask.cs
@@ -51,10 +51,11 @@ namespace Grand.Web.Common.Infrastructure
var runTask = true;
if(task.LastStartUtc.HasValue)
{
- if (DateTime.UtcNow < task.LastStartUtc.Value.AddMinutes(task.TimeInterval))
+ var dateTimeNow = DateTime.UtcNow;
+ if (dateTimeNow < task.LastStartUtc.Value.AddMinutes(task.TimeInterval))
{
runTask = false;
- timeInterval = (int)(DateTime.UtcNow - task.LastStartUtc.Value).TotalMinutes;
+ timeInterval = (int)(task.LastStartUtc.Value.AddMinutes(task.TimeInterval) - dateTimeNow).TotalMinutes;
}
else
{