App: Try to fix auto context renewal
All checks were successful
Test / Run tests (push) Successful in 2m23s

This commit is contained in:
2024-08-30 22:26:49 +02:00
parent 78a72c641f
commit 8c8c0a8c2b

View File

@ -53,7 +53,7 @@ namespace Elwig {
public static Dispatcher MainDispatcher { get; private set; }
private DateTime LastChanged;
private static DateTime CurrentLastWrite => File.GetLastWriteTime(Config.DatabaseFile);
private readonly DispatcherTimer ContextTimer = new() { Interval = TimeSpan.FromSeconds(2) };
private readonly DispatcherTimer ContextTimer = new() { Interval = TimeSpan.FromSeconds(5) };
public App() : base() {
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
@ -70,8 +70,9 @@ namespace Elwig {
}
ContextTimer.Tick += (object? sender, EventArgs evt) => {
if (CurrentLastWrite > LastChanged) {
LastChanged = CurrentLastWrite;
var ch = CurrentLastWrite;
if (ch > LastChanged) {
LastChanged = ch;
OnContextChanged();
}
};