O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Asynchronous Programming

Most of the time, developers write code that processes a series of commands sequentially. For instance, we can envision a simple routine (TallyExpenseReport) that accepts an ID, calls a second routine (GetExpenseReport) to call a service with that ID to retrieve an expense report, grabs the total dollar amount of the expense report, and then updates a database before finally giving the user a message indicating the status of the operation.

C#

public void TallyExpenseReport(string id){    //get the expense report    ExpenseReport rpt = GetExpenseReport(id);    UpdateDataStore(id, rpt.TotalAmt);}public ExpenseReport GetExpenseReport(string id){    //code to fetch an expense report goes here ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required