View Single Post
11/03/21, 09:48 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
https://wiki.esoui.com/Running_LUA-Code_asynchroneously

Having a loop inside a function is not async but sync and will lag the client if the loop takes too long.
A few ms or 1 second is no problem except if this repeats every 1 second again
Like scanning all items of the game will lag the client, so one needs to break it up into portions and scan only 1 portion after another.
Sou you manually do a fragmentation of the whole pile to scan, create packages and scan each package after the next. Each package contains only like 200 itemIds and thus it won't lag the client that much (depends on the user's hardware though).

But depending on the total amount of ids/stuff to scan, and what you are doing with it afterwards (calling API functions to get their level, quality, if it is a set, ...) it will become lagging.
This is why sort of that info is done only once after a patch/APIVersion increase and cached to the SavedVariables.
Often libraries will do that so an addon only needs to use that lib and all benefit from it.

If you tell us what you want to do, maybe here in the dev chat, we would be able to help better.

Last edited by Baertram : 11/03/21 at 09:54 AM.
  Reply With Quote