private static void RunProcess(IBackgroundTask process, ILoggerFactory loggerFactory, TaskContext context)
        {
            TrySetThreadName(process.ToString());

            var logger = loggerFactory.CreateLogger(process.GetProcessType());

            logger.LogDebug($"Background process '{process}' started.");

            try
            {
                process.Invoke(context);
            }
            catch (Exception ex)
            {
                if (ex is OperationCanceledException && context.IsShutdownRequested)
                {
                    // Graceful shutdown
                    logger.LogTrace($"Background process '{process}' was stopped due to a shutdown request.");
                }
                else
                {
                    logger.LogError(
                        $"Fatal error occurred during execution of '{process}' process. It will be stopped. See the exception for details.",
                        ex);
                }
            }

            logger.LogDebug($"Background process '{process}' stopped.");
        }