w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Can exiting an async method yield control back to a different async method?

The outcome doesn't surprise me. If Do3 is ended, I don't see why it should make Do2 continue immediately. It's all part of the asynchronous process, so the actual output makes perfect sense. It wouldn't surprise me, though, if a different run would give a different outcome.

Do3:Bar and Do3:Foo are different tasks, (probably) executed simultaneously in different threads. After they finish, their respective callers are notified, but that notification in itself is probably also asynchronous. await doesn't make two task magically run in the same thread, it just makes the first one wait until the other one is done. So while Do2:Bar is waiting for that signal, Do3:Foo can just continue to run and finish.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.