BackgroundWorkDto add progress to default state message/

This commit is contained in:
ngfrolov 2023-11-02 17:40:51 +05:00
parent 552553bb64
commit 4f45cfc1dd
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 4 additions and 5 deletions

View File

@ -172,7 +172,7 @@ namespace AsbCloudApp.Data
if (progress.HasValue) if (progress.HasValue)
CurrentState.Progress = progress.Value; CurrentState.Progress = progress.Value;
Trace.TraceInformation($"{WorkNameForTrace} state: {newState}"); Trace.TraceInformation($"{WorkNameForTrace} state: {newState} [{100*progress:#}%]");
} }
/// <summary> /// <summary>

View File

@ -19,7 +19,7 @@ public class BackgroundWorker : BackgroundService
public WorkStore WorkStore { get; } = new WorkStore(); public WorkStore WorkStore { get; } = new WorkStore();
public Work? CurrentWork; public Work? CurrentWork;
public Exception? MainLoopLastException { get; private set; } = null; public string MainLoopLastException { get; private set; } = string.Empty;
public BackgroundWorker(IServiceProvider serviceProvider) public BackgroundWorker(IServiceProvider serviceProvider)
{ {
@ -54,14 +54,13 @@ public class BackgroundWorker : BackgroundService
} }
catch (Exception ex) catch (Exception ex)
{ {
MainLoopLastException = ex; MainLoopLastException = $"BackgroundWorker " +
var mainLoopLastException = $"BackgroundWorker " +
$"MainLoopLastException: \r\n" + $"MainLoopLastException: \r\n" +
$"date: {DateTime.Now:O}\r\n" + $"date: {DateTime.Now:O}\r\n" +
$"message: {ex.Message}\r\n" + $"message: {ex.Message}\r\n" +
$"inner: {ex.InnerException?.Message}\r\n" + $"inner: {ex.InnerException?.Message}\r\n" +
$"stackTrace: {ex.StackTrace}"; $"stackTrace: {ex.StackTrace}";
Trace.TraceError(mainLoopLastException); Trace.TraceError(MainLoopLastException);
} }
} }
} }