﻿using System;
using ESPlus.Subscribers;
using Autofac;
using System.Linq;
using System.Threading;

namespace Helix.EventHandler
{
    class Program
    {
        static void Main(string[] args)
        {
            var container = IoC.Build();
            //var manager = container.Resolve<IEventHandlerManager>();

            Run(container.Resolve<ISubscriptionClient>());
            Console.ReadLine();
        }

        private static decimal[] array = new decimal[3];
        private static int index = 0;

        private static void Run(ISubscriptionClient client)
        {
            new Thread(() =>
            {
                while (true)
                {
                    index = (index + 1) % array.Length;
                    array[index] = 0.0m;
                    Thread.Sleep(1000);
                    Console.WriteLine(array.Sum() / array.Length);
                }
            }).Start();

            foreach (var item in client)
            {
                //Console.WriteLine($"Handling event of Position: {item.Position}, EventType: {item.EventType}");
                //eventHandler.DispatchEvent(item);
                ++array[index];
            }
        }
    }
}
