Пример #1
0
        private void FormatPage(WikiPage page)
        {
            var current = Interlocked.Increment(ref x);

            try
            {
                page.Load(formatter);
            }
            catch(Exception ex)
            {
                this.log.Error("Erreur survenue durant le chargement de la page {0} : chargement annulé. Détail de l'erreur : {1}", page.FullName, ex);
            }

            if (current % 10 == 0)
            {
                lock (this)
                {
                    var elapsed = this.watch.ElapsedMilliseconds;
                    if (elapsed > step * stepSize && current != 0)
                    {
                        var totalTime = (elapsed * count) / current;
                        var remaining = TimeSpan.FromMilliseconds(totalTime - elapsed);
                        this.log.Verbose("{0:p1} {1}/{2} (reste {3}m {4}s)", (float)current / count, current, count, (int)remaining.TotalMinutes, remaining.Seconds);
                        this.step = ((int)elapsed / stepSize) + 1;
                    }
                }
            }
        }