Knocks/BackEnd/KnoksExchangeTestApp/Program.cs

53 lines
1.5 KiB
C#

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Knoks.Framework.DataAccess;
using Knoks.Framework.Extentions;
using System.Collections.Generic;
using Knoks.CryptoExchanges;
namespace KnoksExchangeTestApp
{
class Program
{
private static CryptoExchangeManager _exchanges;
private static ILoggerFactory _loggerFactory = new LoggerFactory();
private static ILogger _logger = _loggerFactory.CreateLogger<Program>();
private static bool _isAlive = true;
static void Main(string[] args)
{
try
{
Console.CancelKeyPress += Console_CancelKeyPress;
_exchanges = new CryptoExchangeManager();
_exchanges.StartExchangesRequest();
while (_isAlive) { }
}
catch (Exception exxot)
{
_logger.LogError(exxot, "Pabam! We failed. Press any key to close");
}
finally
{
_exchanges = null;
}
_logger.LogInformation("Tender Events Dispatcher exited.");
Console.WriteLine($"{Environment.NewLine}Press Enter to exit{Environment.NewLine}");
Console.ReadLine();
}
private static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
{
e.Cancel = true;
_exchanges.StopExchangesRequest().Wait();
_isAlive = false;
}
}
}