update on the counting
116c6cdc63ff9c81bb1f5a2176074b071098a5e4
3 files changed
src/OpenKamer.LogicControllers/EntityController.cssrc/OpenKamer.LogicControllers/FeedController.cssrc/OpenKamer.WinForm/Form1.cs
diff --git a/src/OpenKamer.LogicControllers/EntityController.cs b/src/OpenKamer.LogicControllers/EntityController.cs
index 67680d3..b7332f3 100644
--- a/src/OpenKamer.LogicControllers/EntityController.cs
+++ b/src/OpenKamer.LogicControllers/EntityController.cs
@@ -67,11 +67,16 @@ public class EntityController
var list = Directory
.GetFiles(this.FilesDirectory, "*.xml")
- .Select(x => Path.GetFileNameWithoutExtension(x))
+ .Select(x => long.Parse(Path.GetFileNameWithoutExtension(x)))
+ .OrderBy(x => x)
+ .Select(x => x.ToString())
.ToList();
- this.FilesTotal = list.Count;
- this.FilesIndex = list.IndexOf(this.Token);
+ this.FilesIndex = 0;
+ this.FilesTotal = list.Count - list.IndexOf(this.Token);
+
+ list.Clear();
+ GC.Collect();
do
{
@@ -112,6 +117,9 @@ public class EntityController
await ProcessEntitiesAsync(feed, cancellationToken);
+ if (cancellationToken.IsCancellationRequested)
+ return;
+
this.FilesIndex++;
await Task.Delay(100, cancellationToken);
@@ -162,6 +170,10 @@ public class EntityController
await ReplaceEntityByIdAsync(result, cancellationToken);
return result;
}
+ catch(OperationCanceledException)
+ {
+ return default;
+ }
catch (Exception eeee)
{
Debug.WriteLine(eeee.ToString());
@@ -184,6 +196,9 @@ public class EntityController
foreach (var entry in entries)
{
+ if (cancellationToken.IsCancellationRequested)
+ break;
+
if (entry.Content.FirstChild == null)
continue;
diff --git a/src/OpenKamer.LogicControllers/FeedController.cs b/src/OpenKamer.LogicControllers/FeedController.cs
index 08c8d69..1f90afc 100644
--- a/src/OpenKamer.LogicControllers/FeedController.cs
+++ b/src/OpenKamer.LogicControllers/FeedController.cs
@@ -60,11 +60,13 @@ public class FeedController
var list = Directory
.GetFiles(this.FilesDirectory, "*.xml")
- .Select(x => Path.GetFileNameWithoutExtension(x))
+ .Select(x => long.Parse(Path.GetFileNameWithoutExtension(x)))
+ .OrderBy(x => x)
+ .Select(x => x.ToString())
.ToList();
- this.FilesTotal = list.Count;
- this.FilesIndex = list.IndexOf(this.Token);
+ this.FilesIndex = 0;
+ this.FilesTotal = list.Count - list.IndexOf(this.Token);
list.Clear();
GC.Collect();
diff --git a/src/OpenKamer.WinForm/Form1.cs b/src/OpenKamer.WinForm/Form1.cs
index c1cb7e3..28d349b 100644
--- a/src/OpenKamer.WinForm/Form1.cs
+++ b/src/OpenKamer.WinForm/Form1.cs
@@ -97,6 +97,8 @@ public partial class Form1 : Form
this.groupBox1.Enabled = true;
this.progressBar1.Value = 0;
+
+ GC.Collect();
}
async private void Button2_Click(object sender, EventArgs e)
@@ -141,6 +143,8 @@ public partial class Form1 : Form
this.groupBox1.Enabled = true;
this.progressBar1.Value = 0;
+
+ GC.Collect();
}