Ejemplo n.º 1
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Thread.CurrentThread.Name == null)
            {
                Thread.CurrentThread.Name             = "TransferStashWorker";
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            }
            ExceptionReporter.EnableLogUnhandledOnThread();

            BackgroundWorker worker = sender as BackgroundWorker;

            while (!worker.CancellationPending)
            {
                try {
                    Thread.Sleep(1000);
                }
                catch (ThreadInterruptedException) {
                }

                // Nothing queued for looting
                if (_queuedTransferFiles.Count == 0)
                {
                    continue;
                }
                List <UserFeedback> feedback;
                try {
                    var(isLootable, lootableFeedback) = _transferStashService.IsTransferStashLootable();
                    if (isLootable)
                    {
                        feedback = Execute();
                    }
                    else
                    {
                        feedback = lootableFeedback;
                    }
                }
                catch (NullReferenceException ex) {
                    Logger.Warn(ex.Message);
                    Logger.Warn(ex.StackTrace);
                    feedback = UserFeedback.FromTagSingleton("iatag_feedback_unable_to_loot_stash");
                }
                catch (IOException ex) {
                    Logger.Warn(ex.Message);
                    Logger.Warn(ex.StackTrace);
                    Logger.Info("Exception not reported, IOExceptions are bound to happen.");
                    feedback = UserFeedback.FromTagSingleton("iatag_feedback_unable_to_loot_stash");
                }
                catch (Exception ex) {
                    Logger.Warn(ex.Message);
                    Logger.Warn(ex.StackTrace);
                    ExceptionReporter.ReportException(ex, "EmptyPageX??");
                    feedback = UserFeedback.FromTagSingleton("iatag_feedback_unable_to_loot_stash");
                }

                _feedbackService.Print(feedback);
            }
        }