protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { try { _statusService.LogicStarted(); await _logic.Perform(stoppingToken); _statusService.LogicCompleted(); } catch (Exception e) { _statusService.LogicError(e); _log?.Error("Error when perform task logic", e).Write(); } await Task.Delay(_period, stoppingToken); } }
/// <summary> /// Report about task logic error /// </summary> public static void LogicError(this ITaskStatusService srv, Exception e) { srv.LogicError(new StatusError(e)); }