Using async / await

Sunday, January 15, 2012

Using async / await this post will discuss parallel disposal. whenever we want to dispose a parallel execution upon completion we can't use the convenient using keyword. for example, the following code may be dispose the command before completion: Very bad Code Snippet using (var conn = new SqlConnection(CONN_STR)) using (var cmd = new SqlCommand("Select * from Employee", conn)) {     conn.Open();     cmd.BeginExecuteReader(ar =>         {             int affected = cmd.EndExecuteNonQuery(ar);         }); } the using is absolutely wrong for the above sample. what should be...

the concept of async \ await

Thursday, December 29, 2011

the concept of async \ await in this post I will survey the new .NET 4.5 / C# 5 concept of async / await. I will focus on how to understand what is really happens behind the new async / await syntax. What's it all about? the new async / await syntax is using the C# syntactic compiler to generate async operation from code that is looking very much like a synchronous code. but before we start we should discus the new C# 5  syntax. the syntax include 2 keywords: ...

What is the cost of async/await?

Thursday, December 15, 2011

What is the cost of async/await? .NET 4.5 (C# 5) had brought the new async/await syntax. I will cover async/await syntax in more details in future post, but in the meanwhile in case that you are not yet familiar with this syntax, what's  you should have to know is that the syntactic compiler transform that syntax (and the lines that follow the await keyword) into IL, the generated IL is following the concept of the TPL ContinueWith. the syntactic compiler is actually generating fair amount of IL which represent a state-machine of the async execution. ...
no comments