Skip to content

Commit 84ad149

Browse files
Wrap time prediction in a try block for safety
1 parent ea210df commit 84ad149

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Src/FinderOuter/Models/Report.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,22 @@ private void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e
207207
{
208208
if (Progress is > 0 and <= 100)
209209
{
210-
TotalChecked = (double)Total * Progress / 100;
211-
double time = Timer.Elapsed.TotalSeconds;
212-
if (time != 0 && TotalChecked != 0)
210+
try
213211
{
214-
Speed = TotalChecked / time;
215-
double remKeys = (double)Total - TotalChecked;
216-
Debug.Assert(remKeys >= 0);
217-
double d = remKeys / Speed;
218-
Remaining = TimeSpan.FromSeconds(d);
212+
TotalChecked = (double)Total * Progress / 100;
213+
double time = Timer.Elapsed.TotalSeconds;
214+
if (time != 0 && TotalChecked != 0)
215+
{
216+
Speed = TotalChecked / time;
217+
double remKeys = (double)Total - TotalChecked;
218+
Debug.Assert(remKeys >= 0);
219+
double d = remKeys / Speed;
220+
Remaining = TimeSpan.FromSeconds(d);
221+
}
222+
}
223+
catch (Exception ex)
224+
{
225+
Debug.Fail(ex.Message);
219226
}
220227
}
221228
}

0 commit comments

Comments
 (0)