Posts

Showing posts from September, 2017

Web developers dilemma with async in C#

Most web developers use asynchronous programming in Javascript. Most of us have done ajax calls and handled callbacks. Probably if there was an alternative (simple) programmers would have preferred a synchronous way of calling api. You can find many questions in Stackoverflow over this. Even though JQuery can do synchronous api calls you still need to code in the same way. I think this is the reason we became familiar with asynchronous programming in Javascript rather than benefit of programming that way. function GetWebData(){    var webData;     jQuery.ajax({         url: apiUrl,         success: function(data) {         webData = data;     },     async:false   });     return webData; } This does work synchronously. But syntax remains same. So we figured out handling the results in success using callbacks. But these lessons remained in Javascript programming. You can hardly see async await keywords in C# (introduced in 2012). One reason for this - it is hard to think async. We learn