public void DoWork()
        {
            while (_keepAlive)
            {
                while (_isRunning)
                {
                    try
                    {
                        if (_needDelay)
                        {
                            Thread.Sleep(_delay);
                        }

                        foreach (Account account in Config.Singleton.AccountSettings.ToArray())
                        {
                            var results = new List <ComponentResult>();
                            foreach (
                                ComponentClass component in
                                ComponentManager.Singleton.GetComponents().ToArray().Where(c => c.IsEnabled))
                            {
                                var result = new ComponentResult();
                                component.Component.DoWork(account, ref result);
                                results.Add(result);
                            }
                            if (results.Any(r => r.Result == EComponentResult.KillForced))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                        results.Where(r => r.Result == EComponentResult.KillForced))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                                                 account.LoginName);
                                    }
                                }
                                new KillWorker().DoWork(account).Update(account);
                            }
                            else if (results.Any(r => r.Result == EComponentResult.HaltForced))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                        results.Where(r => r.Result == EComponentResult.HaltForced))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                                                 account.LoginName);
                                    }
                                }
                                account.SetLastStopTime(DateTime.Now);
                            }
                            else if (results.Any(r => r.Result == EComponentResult.StartForced))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                        results.Where(r => r.Result == EComponentResult.StartForced))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                                                 account.LoginName);
                                    }
                                }
                                new StartWorker().DoWork(account);
                            }
                            else if (results.Any(r => r.Result == EComponentResult.ContinueForced))
                            {
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Kill))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                        results.Where(r => r.Result == EComponentResult.Kill))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                                                 account.LoginName);
                                    }
                                }
                                new KillWorker().DoWork(account).Update(account);
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Halt))
                            {
                                if (Config.Singleton.GeneralSettings.ExtensiveLogging)
                                {
                                    foreach (
                                        ComponentResult componentResult in
                                        results.Where(r => r.Result == EComponentResult.Halt))
                                    {
                                        Logger.LoggingObject.Log(ELogType.Debug, componentResult.LogMessage,
                                                                 account.LoginName);
                                    }
                                }
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Start))
                            {
                                if (VersionControl.CheckVersionBot())
                                {
                                    new StartWorker().DoWork(account).Update(account);
                                }
                                else
                                {
                                    VersionControl.Update();
                                }
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Continue))
                            {
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Ignore))
                            {
                            }
                            else if (results.Any(r => r.Result == EComponentResult.Default))
                            {
                            }
                        }
                        User32.EnumWindows(EnumTheWindows, IntPtr.Zero);

                        IEnumerable <Process> gw2Processes = UpdateListWithRemainingGW2Processes();

                        if (_checkAll || Config.Singleton.GeneralSettings.PollingDelay >= 60)
                        {
                            Process[] enumerable = gw2Processes as Process[] ?? gw2Processes.ToArray();
                            foreach (Process gw2Process in enumerable)
                            {
                                UpdateProcessIdForMatchingScheduler(gw2Process);
                                if (!gw2Process.Responding)
                                {
                                    if (FrozenGW2Windows.All(p => p.Key.Id != gw2Process.Id))
                                    {
                                        AddUnresponsiveProcessToTheList(gw2Process);
                                    }
                                    else
                                    {
                                        GetRidOfProcessesThatHaveBeenFrozenForLong(gw2Process);
                                    }
                                }
                                else
                                {
                                    if (_enableViewStateChecks)
                                    {
                                        var viewState = (EViewState)GW2MinionLauncher.ViewState((uint)gw2Process.Id);
                                        //GetViewState(gw2Process);
                                        if (viewState != EViewState.ViewGameplay &&
                                            DeadGW2Windows.All(p => p.Key.Id != gw2Process.Id))
                                        {
                                            AddDeadProcessToTheList(gw2Process, viewState);
                                        }
                                        else if (viewState != EViewState.ViewGameplay)
                                        {
                                            GetRidOfProcessesThatHaveBeenIdleForLong(gw2Process, viewState);
                                        }
                                        else
                                        {
                                            RemoveWorkingWindowsFromTheList(gw2Process);
                                        }
                                    }
                                    RemoveRespondingWindowsFromTheList(gw2Process);
                                    MinimizeGW2Windows(gw2Process);
                                }
                            }
                            //if (_buildNumberNeedUpdate == 0)
                            //{
                            //    try
                            //    {
                            //        _buildNumber = GW2MinionLauncher.BuildNumberFromApi();
                            //        //VersionChecker.CheckForUpdates();
                            //    }
                            //    catch
                            //    {
                            //        _buildNumber = 0;
                            //    }
                            //    _buildNumberNeedUpdate = 0;
                            //    try
                            //    {
                            //        if (enumerable.Any())
                            //            _enableViewStateChecks =
                            //                GW2MinionLauncher.BuildNumber((uint) enumerable.First().Id) == _buildNumber;
                            //        && _buildNumber == Pointers.BuildNumber;
                            //    }
                            //    catch
                            //    {
                            //        _enableViewStateChecks = false;
                            //    }
                            //}
                            //_buildNumberNeedUpdate++;
                            //if (_buildNumberNeedUpdate > 30)
                            //    _buildNumberNeedUpdate = 0;
                        }
                        _checkAll = !_checkAll;
                    }
                    catch (Exception)
                    {
                    }
                    Thread.Sleep(Config.Singleton.GeneralSettings.PollingDelay * 1000);
                }
                Thread.Sleep(10000);
            }
        }