Problem with the first iteration in the loop, wont wait the set delay
I'm basically trying to iterate through users and then add a delay for each iteration, delay is user set. There is however a base delay that is also user set, I just calculate the final delay with base delay + delay. I use a variable to calculate which user its at, if its the first then its 0, second 1, third 2 etc. It resets after all the users have been done sending. Problem is, the first user sends instantly after 1 second, ignoring the delay.
13 Replies
this is for learning purposes and I do not condone using user tokens and requesting HTTP via discord api
I am a beginnering and I am trying to learn by doing. This will not be used for discord but rather for educational purposes only.
What I don't understand is why the heck the first iteration wont wait the set delay
this is what debugging tells me:
Index: 0, Delay: 3
Message sent successfully from ryze07
reached task.delay
It tells me the correct base delay
But it instantly sendsyou just do
await Task.Delay(100);
?
is that supposed to be await Task.Delay(delay);
?
or tokenDelay
, or finalDelay
moving some code away in other methods would help outline the logic
or even just removing some indentation layer
Thats just a small delay before the iteration happend, thats supposed to be like that. Incase something happens and it needs that, really I just put it there to see if it would work
Ill do that sorry
await Task.Delay(finalDelay * 1000) is the main wait, *1000 is so it is counted in seconds.
ok but do you agree that
Delay(finalDelay * 1000)
happens after http call has been madeoh
dude
im so stupid
thank you so much
idk how i didnt notice that
dynamic
🤮what? is there a dynamic and i didn't see it?
edit: the deserialization...
also Convert.ToInt32 should be TryParse
Will try thanks
Isnt dynamic a faster option ?
No
It's the least performant way you could've possibly chosen
and painful
Oh, how uneducated i am
Also, could use the built-in JSON serialization instead of Newtonsoft, maybe
Depending on the context this code is used in