Tuesday, May 3, 2011

Deciding Factor for Asynchronous Programming

What could be the deciding factor to use the methods asynchronously.

One factor i can understand is independent and parallel execution so as to save time and uses the available resources.

What could be the other factors ???

Any help is highly appreciated.

From stackoverflow
  • Providing feedback and allowing for call cancellation - you can cancel a call at any time gracefully.

  • Slow input, doing it asynchronously allows you to do processing (Also allows you to respond to user events) while you wait for the input to complete. Most networking functions can be implemented this way (Through callbacks, etc).

  • Providing responsiveness and feedback in the user interface, in order to keep the users happy and buying more software.

    Maghis : +1 for buying more software:)
    • Allow the user to do other tasks (or cancel) during the execution
    • Allow the software to do other tasks during the execution
      • Eg. Using processor time while waiting for network or file system
      • Communication with external processes or devices which need immediate response to not run into a timeout. (Eg. Network response, external devices)

    It's good praxis to not bind two different time consuming tasks synchronously together, eg. network communication and Database access.

    On the other hand, software does not get faster if everything is asynchronous. It just allows using resources while waiting for others.

  • Allowing the UI to remain responsive during long running processes is a big plus. Some users tend to end task once they see that dreaded "Not Responding" in the applications title bar. I'd much rather display a progress bar in order to distract the user :).

  • One thing to remember is that once you jump the hurdle of asynchronous programming, you can do more than two things at once.

    In other words, going from synchronous programming to asynchronous programming can be daunting. However, once you're there, you can fire off many things asynchronously and improve your program's efficiency.

0 comments:

Post a Comment