Improve resource disposal practices

Wraps enumerators and commands in proper using blocks to ensure cleanup.
Adds async disposal for enumerators, reducing resource leakage risks.
This commit is contained in:
Darnell Williams
2025-05-29 15:04:17 -05:00
parent 3951c49e1a
commit 2cfd1b1487
4 changed files with 32 additions and 15 deletions
+3 -1
View File
@@ -134,7 +134,9 @@ public class DbViewer : Window
// We only want to fetch count if this is the first page
if (CurrentPage == 1)
Count = Plugin.MessageManager.Store.CountDateRange(AfterDate, BeforeDate, channels, character);
Messages = Plugin.MessageManager.Store.GetDateRange(AfterDate, BeforeDate, channels, character, CurrentPage - 1).ToArray();
using var dateRangeMessageEnumerator = Plugin.MessageManager.Store.GetDateRange(AfterDate, BeforeDate, channels, character, CurrentPage - 1);
Messages = dateRangeMessageEnumerator.ToArray();
Filter();
}