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)
CurrentState.Progress = progress.Value;
Trace.TraceInformation($"{WorkNameForTrace} state: {newState}");
Trace.TraceInformation($"{WorkNameForTrace} state: {newState} [{100*progress:#}%]");
}
/// <summary>

View File

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