DCSIMG
continuation - Bnaya Eshet

Bnaya Eshet

Disclaimer

Browse by Tags

All Tags » continuation (RSS)
Parallel and The C# Memory Model
Parallel and The C# Memory Model Parallel programming can be tricky , both compiler and CPU's optimization can lead into a twilight zone's debugging. lets take the following code snippet snippet: Code Snippet class Program { static void Main( string [] args) { Console .WriteLine( "Start" ); var u = new Util (); u.Exec(); Console .ReadKey(); } } public class Util { private bool _stop = true ; public void Exec() { Task t = Task .Run(() => { bool b = true ; while (_stop) { b = ...
Using async / await
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...
async \ await and Exception Handling
async \ await and Exception Handling this post will discuss how async / await is handling exceptions . as we mention in previous post , about the async / await concept, await is all about continuation . before .NET 4.5 parallel execution exceptions has to be handle in separate of the synchronic handling. for example: handling ThreadPool execution: Code Snippet void Foo() { try { Console .WriteLine( "Synchronic" ); ThreadPool .QueueUserWorkItem(state => { try { Console .WriteLine( "Parallel"...
the concept of async \ await
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: async - which is only a marker...