private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            try {
                if (Thread.CurrentThread.Name == null)
                {
                    Thread.CurrentThread.Name = "StatParserUI";
                }

                logger.Info("Updating player stats");

                BackgroundWorker worker = sender as BackgroundWorker;


                // Update all stats
                playerItemDao.ClearAllItemStats();
                IList <PlayerItem> items = playerItemDao.ListAll();
                worker.ReportProgress(Math.Max(100, items.Count), 1);


                int total = 0;
                playerItemDao.UpdateAllItemStats(items, (p) => {
                    worker.ReportProgress(total++, 0);
                });
                logger.Info("Updated item stats");
            }
            catch (Exception ex) {
                logger.Fatal(ex.Message);
                logger.Fatal(ex.StackTrace);
                //ExceptionReporter.ReportException(ex);
                throw;
            }
        }
Пример #2
0
 public void UpdateAllItemStats(IList <PlayerItem> items, Action <int> progress)
 {
     ThreadExecuter.Execute(
         () => repo.UpdateAllItemStats(items, progress)
         );
 }