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:
parent
050ef3c133
commit
04b4e872a8
1 changed files with 40 additions and 35 deletions
|
|
@ -8,6 +8,7 @@ using System.Text.Json;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Swan;
|
using Swan;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SecondBotEvents.Services
|
namespace SecondBotEvents.Services
|
||||||
{
|
{
|
||||||
|
|
@ -28,6 +29,9 @@ namespace SecondBotEvents.Services
|
||||||
|
|
||||||
public void InventoryUpdateEvent(Dictionary<string, string> detail)
|
public void InventoryUpdateEvent(Dictionary<string, string> detail)
|
||||||
{
|
{
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
|
||||||
detail["itemtype"] = detail["itemtype"].ToLower().FirstCharToUpper();
|
detail["itemtype"] = detail["itemtype"].ToLower().FirstCharToUpper();
|
||||||
if (InventoryEvents.ContainsKey(detail["itemtype"]) == true)
|
if (InventoryEvents.ContainsKey(detail["itemtype"]) == true)
|
||||||
{
|
{
|
||||||
|
|
@ -66,6 +70,7 @@ namespace SecondBotEvents.Services
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, List<string>> InventoryEvents = [];
|
Dictionary<string, List<string>> InventoryEvents = [];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue