From 8d17a88f3def3ef9541583a40aafbd075df120da Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Thu, 26 Oct 2023 09:13:56 +0500 Subject: [PATCH] Fix TelemetryDataCache.InitializeCacheFromDBAsync --- .../Services/SAUB/TelemetryDataCache.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataCache.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataCache.cs index 22b65694..0946de01 100644 --- a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataCache.cs +++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataCache.cs @@ -163,15 +163,16 @@ namespace AsbCloudInfrastructure.Services.SAUB private async Task InitializeCacheFromDBAsync(IAsbCloudDbContext db, Action onProgress, CancellationToken token) where TEntity : class, AsbCloudDb.Model.ITelemetryData { - try - { - if (isLoading) - throw new Exception("Multiple cache loading detected."); + var defaultTimeout = db.Database.GetCommandTimeout(); + db.Database.SetCommandTimeout(TimeSpan.FromMinutes(5)); + if (isLoading) + throw new Exception("Multiple cache loading detected."); + + try + { isLoading = true; - db.Database.SetCommandTimeout(TimeSpan.FromMinutes(5)); - Well[] wells = await db.Set() .Include(well => well.Telemetry) .Include(well => well.Cluster) @@ -198,7 +199,6 @@ namespace AsbCloudInfrastructure.Services.SAUB finally { isLoading = false; - var defaultTimeout = db.Database.GetCommandTimeout(); db.Database.SetCommandTimeout(defaultTimeout); } }