c# - Awaiting last method call -


a few posts on stack overflow have suggested following:

any async method have single await expression awaiting task or task < t >, right @ end of method no further processing, better off being written without using async/await.

architecture async/await

await or return

is advice particular circumstances? on web server, isn't 1 of main reasons use async/await, being while awaiting updatedataasync method below, thread return threadpool, allowing server work on other requests?

should savedataasync await db update call given it's last call in method?

public async task workwithdataasync(data data) {     manipulatedata(data);     await savedataasync(data);     await senddatasomewhereasync(data); }  public async task savedataasync(data data) {     fixdata(data);     await dbconnection.updatedataasync(data); } 

also, given don't know savedataasync used, making synchronous hurt method workwithdataasync not?

removing await , returning task doesn't make method synchronous. await tool makes easier make method asynchronous. it's not only way make method asynchronous. it's there because allows add continuations task more without it, in method you've shown you're not leveraging await keyword accomplish anything , such can remove , have code function identically.

(note technically semantics of exceptions have been changed removing async; thrown exceptions thrown method, not wrapped in returned task, if matters you. far caller concerned, observable difference.)


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -