That's because if you were doing say 10000 loops, that might take 5 seconds. But when you use an OnUpdate, and your code is doing 1 loop per OnUpdate, then since Onupdates run once every frame, you'll be taking 10000 frames to run the entirety of your loops. If you play wow at say 100 FPS, then that's 100 seconds, or 1 minute 40 seconds.
The solution? Run say 10 loops per OnUpdate/frame, not 1, and that 100 seconds becomes 10 seconds, and you can animate a nice progress bar while you're at it over the 1000 frames in that 10 seconds.
Well, after messing with a C Stack Overflow error for an hour or so, I got it to work doing 25 at a time (which is a single page in my addon) and it takes like 10 seconds instead of 5, which is acceptable considering it's visual and it's not hung-up time.
Thanks a tun! I don't know if it's too much better then it was but I did learn a lot in the process. Looks like it works great now.
So like a loop with events? Interesting, I haven't thought of that. I do have another question though, if I do it that way, will it take longer to complete? I don't want to have a status bar at the expense of making my users wait too much longer.
Ok, I'm writing an AddOn that stores data, then shows it back as a list in a ScrollingMessageFrame. It works fine, except when the amount of data gets too large, it takes a few seconds for the for loop to add everything to the frame.
I wanted to add a StatusBar in order to show the progress, so the user knows how long to wait. The only problem is, the for loop locks up the game while executing, so for the few seconds it takes, the status bar doesn't appear to move. When it's done, the status bar appears filled, telling me it's done.
I was wondering if there was some function to re-draw the frame, so that it'll refresh the StatusBar each time it updates, while stuck in the loop? Or, is there a sleep or wait function I can add something like 1 millisecond each time to allow the game to continue and update it? Or perhaps another solution?
Note: I'm new to lua, but I have done a lot of programming in other languages, so I just had to pick up the Lua Syntax and API.
Thanks in Advance.