Contents tagged with Asynchronous

  • AsyncController v/s SessionLess Controller

        Introduction:

              AsyncController is introduced in ASP.NET MVC 2 while SessionLess controller is introduced in ASP.NET MVC 3. AsyncController allows you to perform long running I/O operation(s) without making your thread idle(i.e., waiting for I/O operations to complete). On the other hand, SessionLess controller allows you to execute multiple requests simultaneously for single user, which otherwise execute multiple requests sequentially due to session synchronization. Understanding these concepts may be easy for you but I have seen a lot of guys become confused on these concepts. In this article, I will show you how to use AsyncController and SessionLess controller in ASP.NET MVC application. I will also compare them and tell you what to use when, where, and the why.

  • Race Condition in AsyncController

         Introduction:

              ASP.NET MVC 2 provides AsyncController which enables you to define controller actions that run asynchronously. AsyncController become very useful in IO bound tasks, for example calling a remote web service or query large amounts of data from a slow database, etc. In these situation you will not tie up a request processing thread(ASP.NET thread), instead you use AsyncController which enables you to use non-ASP.NET thread to execute long IO bound operations. AsyncController will increase overall application performance if your application is using long running IO bound task. Synchronization is very important if you are performing multiple task in AsyncController, but if you don't care then your application may come into a situation that we refer to as a race condition. Race condition occurs when several threads attempt to access the same data and do not take account of what the other threads are doing which result in corrupt data structures. So in this article I will show you how your application may come into race condition situation and how you can avoid race condition situation.