Make InventoryUpdateEvent asynchronous

Wraps InventoryUpdateEvent logic in a Task to run asynchronously, improving responsiveness and preventing blocking of the main thread during event processing.
This commit is contained in:
Madpeter 2025-10-04 23:05:56 +01:00
parent 050ef3c133
commit 04b4e872a8

View file

@ -8,6 +8,7 @@ using System.Text.Json;
using System.Linq;
using Swan;
using RestSharp;
using System.Threading.Tasks;
namespace SecondBotEvents.Services
{
@ -28,6 +29,9 @@ namespace SecondBotEvents.Services
public void InventoryUpdateEvent(Dictionary<string, string> detail)
{
Task.Run(() =>
{
detail["itemtype"] = detail["itemtype"].ToLower().FirstCharToUpper();
if (InventoryEvents.ContainsKey(detail["itemtype"]) == true)
{
@ -66,6 +70,7 @@ namespace SecondBotEvents.Services
}
}
});
}
Dictionary<string, List<string>> InventoryEvents = [];