progressbar stops at 100%

Alphons van der Heijden <alphons@heijden.com> 4 Jan 2023, 20:28
b73e5188f8b09f70400fd25902eb0095d739f45e
2 files changed
  • src/OpenKamer.LogicControllers/EntityController.cs
  • src/OpenKamer.WinForm/Form1.cs
diff --git a/src/OpenKamer.LogicControllers/EntityController.cs b/src/OpenKamer.LogicControllers/EntityController.cs
index fa73d37..83f9784 100644
--- a/src/OpenKamer.LogicControllers/EntityController.cs
+++ b/src/OpenKamer.LogicControllers/EntityController.cs
@@ -65,6 +65,8 @@ public class EntityController
do
{
+ await Task.Delay(100, cancellationToken);
+
this.FileCount++;
var FileName = FilesDirectory + @"\" + SkipToken + ".xml";
@@ -175,8 +177,6 @@ public class EntityController
if (entry.Content.FirstChild == null)
continue;
- await Task.Delay(1, cancellationToken);
-
switch (entry.Category.Term)
{
default:
diff --git a/src/OpenKamer.WinForm/Form1.cs b/src/OpenKamer.WinForm/Form1.cs
index efcdb01..b6a8dee 100644
--- a/src/OpenKamer.WinForm/Form1.cs
+++ b/src/OpenKamer.WinForm/Form1.cs
@@ -150,7 +150,7 @@ public partial class Form1 : Form
this.lblCount.Text = this.entityController1.EntityCount.ToString();
this.lblErrors.Text = this.entityController1.Error.ToString();
- this.progressBar1.Value = (this.entityController1.FileCount / 200);
+ this.progressBar1.Value = Math.Min(100, (this.entityController1.FileCount / 200));
this.labelStatus.Text = $"Files: {this.entityController1.FileCount}";
@@ -168,7 +168,7 @@ public partial class Form1 : Form
this.lblCount.Text = this.feedController1.FileCount.ToString();
- this.progressBar1.Value = (this.feedController1.FileCount / 200);
+ this.progressBar1.Value = Math.Min(100, (this.feedController1.FileCount / 200) );
var speed = (1000 * this.feedController1.FileCount) / this.sw.ElapsedMilliseconds;