C
C#2y ago
Lexa

❔ While loop stuck

Hey, someone has an idea why after running a method my while loop just stops ? thank you
12 Replies
Buddy
Buddy2y ago
Tasks are not long-running unless you specify them to be
Angius
Angius2y ago
(also, nice discarded task)
Lexa
LexaOP2y ago
is that ironic ?
Lexa
LexaOP2y ago
I'am doing this in an other method, could you explain why it does't work here ?
Angius
Angius2y ago
For the time being, yes. Tasks should, generally, be awaited. But you might have reasons to fire&forget it, dunno
Lexa
LexaOP2y ago
so you have any idea how to solve my issue ? could use thread
Buddy
Buddy2y ago
You can spawn a Thread instead of a Task, as you pretty much have no reason to use Task. for the first example
Lexa
LexaOP2y ago
why not the second one ?
mtreit
mtreit2y ago
There's no particular advantage to using a Thread object instead of a Task object and Thread has a much less ergonomic API. Just use Task.Factory.StartNew with the TaskCreationOptions.LongRunning flag. (To avoid burning a thread pool thread unnecessarily)
Lexa
LexaOP2y ago
is it clean now ?
Lexa
LexaOP2y ago
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server