4 ms·
I think I might not have explained myself too well up there. I was referring to entirely sequential async calls. Like: ``` Thing thing = await loadThing(); Thin
by ajxs 8y ago
I think I might not have explained myself too well up there. I was referring to entirely sequential async calls. Like:
```
Thing thing = await loadThing();
Thing other = await thing.doSomething();
thing = await saveThing();
// repeat x1000...
```
I see this over and over.
- mschuetz 8y agoAnd what exactly is the problem with that? "Thing thing = await loadThing(); ": Start loading thing, then await so the main thread can continue doing other stuff while thing is loaded. "Thing other = await thing.doSomething();": Invoke some other function that does some stuff in the background, then await so the main thread can continue doing other stuff while thing does something. "thing = await saveThing();": Saving can often be done in parallel so no need to block the App while something is saved. Invoke the save function, then await so the main thread can continue doing other stuff while thing is saved. This gets you the advantages of async programming while still maintaining a legible coding style that looks similar to common synchronous code.