fix check CDM status

This commit is contained in:
Nguyen Dinh Thuan
2024-09-17 23:28:02 +07:00
parent cdf3ab64f9
commit 56ba2b199b
3 changed files with 26 additions and 18 deletions
+23 -15
View File
@@ -50,22 +50,30 @@ namespace SafeBagDE70.Admin
public void Emit(LogEvent logEvent)
{
var message = logEvent.RenderMessage(_formatProvider);
var logLevel = logEvent.Level.ToString();
var timestampedMessage = $"[{logEvent.Timestamp:HH:mm:ss}] [{logLevel}]{message}";
try
{
var message = logEvent.RenderMessage(_formatProvider);
var logLevel = logEvent.Level.ToString();
var timestampedMessage = $"[{logEvent.Timestamp:HH:mm:ss}] [{logLevel}]{message}";
// Ensure the message is added on the UI thread
App.Current.Dispatcher.Invoke(() => {
AppData.logCollection.Add(timestampedMessage);
if (AppData.logCollection.Count > AppData.MaxLogCount)
{
AppData.logCollection.RemoveAt(0); // Remove the oldest event
}
if (AppData.logListView != null && AppData.logListView.Items.Count > 0)
{
AppData.logListView.ScrollIntoView(AppData.logListView.Items[AppData.logListView.Items.Count - 1]);
}
});
// Ensure the message is added on the UI thread
App.Current.Dispatcher.Invoke(() => {
AppData.logCollection.Add(timestampedMessage);
if (AppData.logCollection.Count > AppData.MaxLogCount)
{
AppData.logCollection.RemoveAt(0); // Remove the oldest event
}
if (AppData.logListView != null && AppData.logListView.Items.Count > 0)
{
AppData.logListView.ScrollIntoView(AppData.logListView.Items[AppData.logListView.Items.Count - 1]);
}
});
}
catch(Exception ex)
{
}
}
}
}