Example #1
0
        protected void Application_Start()
        {
            DependenciesConfigurator.InitLogger(this.Server.MapPath("~/bin/"));

            GlobalConfiguration.Configure(WebApiConfig.Register);
            GlobalConfiguration.Configure(ContainerConfig.Configure);
        }
Example #2
0
        public static int Main(string[] args)
        {
            DependenciesConfigurator.InitLogger();

            try
            {
                Run().Wait();
            }
            catch (Exception exception)
            {
                Logger.Instance.Error(exception);

                return(-1);
            }
            finally
            {
#if DEBUG
                Console.ReadKey();
#endif
            }

            return(0);
        }
Example #3
0
        public static int Main(string[] args)
        {
            DependenciesConfigurator.InitLogger();

            try
            {
                var container = Initialize();

                GetPredictions(container).Wait();

                ConfigureWatcher(container);

                // Process the watcher queue.
                Task.Factory.StartNew(async() =>
                {
                    var logger = container.GetInstance <ILogger>();

                    while (true)
                    {
                        if (isClosing)
                        {
                            break;
                        }

                        ManualResetEvent.WaitOne();

                        try
                        {
                            if (isClosing)
                            {
                                break;
                            }

                            // Delay to handle bulk operations.
                            Thread.Sleep(TimeSpan.FromSeconds(2));

                            while (!WorkerQueue.IsEmpty)
                            {
                                DateTime item;
                                if (!WorkerQueue.TryDequeue(out item))
                                {
                                    break;
                                }
                            }

                            await GetPredictions(container);
                        }
                        catch (Exception exception)
                        {
                            logger.Error("Could not predict.", exception);
                        }
                        finally
                        {
                            ManualResetEvent.Reset();
                        }
                    }
                });

                Console.ReadKey();
                isClosing = true;
                ManualResetEvent.Set();
            }
            catch (Exception exception)
            {
                Logger.Instance.Error(exception);

                return(-1);
            }
            finally
            {
#if DEBUG
                Console.ReadKey();
#endif
            }
            return(0);
        }