❔ Task.WhenAll does not work without Task.Run inside
Inside a task,
_pathFinder.FindPath
is not called.
returnFirstPath
is false (Task.WhenAll)
but if I change list.Add(new Task<PathResult>(action));
to list.Add(Task.Run(action));
, it works.
Another question, I should use Task.Run to be sure it runs in different threads and get results faster?
30 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yes, I said Task.Run is OK but without it, it is not called at all
Using await await for Task.WhenAny because it returns Task<Task<>>
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
list.Add(new Task<PathResult>(action));
It is
I want to know if I can use Task.WhenAll without Task.Run or not, surely I should be able to use it with simple tasks
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I have tested, my above code is not called
.
I have put break points here
var pathResult = _pathFinder.FindPath
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
tebeco#0205
REPL Result: Success
Result: ValueTuple<int, int>
Compile: 639.115ms | Execution: 99.819ms | React with ❌ to remove this embed.
😐
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
tebeco#0205
REPL Result: Failure
Exception: CompilationErrorException
Compile: 638.056ms | Execution: 0.000ms | React with ❌ to remove this embed.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
What a terrible design
It gets Task but it does not work, really shit design
OK, thanks dudes
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
If I call Start, it works. Yes, those tasks are required to be started
Appreciated
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Now, it is like Task.Run in terms of multi threading? it can be executed in different threads or
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
OK, I test it
By the way, in my testing Task.Run is handling it very well
10 tasks around 100 sec but now it is 11 sec
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yes, faster is better 🙂
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Because, sometimes a path can take huge time
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Maybe, but I am tireddd
It is A* algorithm path finding
with large path length
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I'm not aware of such a thing.
At least, I can run the algorithm with each target point parallelly.
It is my first simplest option
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
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.