Skip to main content

Posts

Showing posts with the label AsyncAwait

Parallel Programming

If you are writing multi threaded application with .Net , there are various options to choose from. There is Thread,Background worker, delegate etc.  .Net framework 4.5 has introduced another approach towards parallel programming " a sync and await" .  With async n await, code follows a logical structure which looks similar to synchronous code and provides benefits of asynchronous programming. Above is an example of a program which downloads the historical prices from Yahoo finance and saves it as a csv file.  Here Act_Async is an asynchronous method which makes a call to GetStreamAsync and after that performs some operations  (which are some print operation for ex.) . Once those operation are complete and it requires the output of  GetStreamAsync , it await on the return object (which is stream in this case). Once await is called, control is returned to the calling code (which is main method). In Ma...