using OF_DL.Services;
using Serilog;

namespace OF_DL.Helpers;

public class ExitHelper(IDownloadEventHandler eventHandler)
{
    private readonly IDownloadEventHandler _eventHandler = eventHandler;

    public void ExitWithCode(int exitCode)
    {
        Console.WriteLine();

        _eventHandler?.OnMessage($"Exiting run with Code '{exitCode}'..");

        Log.CloseAndFlush();
        Log.CloseAndFlush();
        Task.Delay(3000).GetAwaiter().GetResult();

        Environment.Exit(exitCode);
    }
}
