Fix: Trycatch on base program.cs to prevent crash

This commit is contained in:
arham committed 2025-12-03 12:21:03 +00:00
1 parent 14a79b6352
commit aabf1490eb
1 file changed
+13 -1
+13 -1
View File
@@ -16,6 +16,7 @@
using System.Threading.Tasks;
using System.Threading;
using bts.md;
using MathNet.Numerics.Optimization;
class Program {
[Flags]
@@ -78,8 +79,19 @@
var vsdTask = Task.Run(() => {
Log.Gen.info("Starting ViewStreamDatabase work loop");
var cancellationToken = cancellationTokenSource.Token;
var counter = 0;
const int ERROR_LIMIT = 4;
while (!cancellationToken.IsCancellationRequested) {
ViewStreamDatabase.instance.doWork();
try {
ViewStreamDatabase.instance.doWork();
counter = 0;
} catch (Exception ex) {
counter++;
Log.Gen.error(ex.Message);
}
if (counter >= ERROR_LIMIT) {
throw new Exception("counter limit reached");
}
Thread.Sleep(100);
}
}, cancellationTokenSource.Token);