Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple async calls in the same statement in C#

Tags:

c#

Are all calls happening even if the first returns false? Is the second one waiting for the first one?

if (await callAsync() && await callAsync()) {...}

if (await callAsync() & await callAsync()) {...}

if (await callAsync() || await callAsync()) {...}

like image 779
Carlos Garcia Avatar asked Jan 25 '23 05:01

Carlos Garcia


1 Answers

In both cases, the calls still happen sequentially in the execution flow, not in parallel. In the first case the second call only happens if the first returns true; in the second case, both will happen either way (assuming no exceptions are thrown).

like image 148
Marc Gravell Avatar answered Jan 28 '23 13:01

Marc Gravell