From the course: Asynchronous Programming in C#

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

When and why to write asynchronous code

When and why to write asynchronous code - C# Tutorial

From the course: Asynchronous Programming in C#

When and why to write asynchronous code

- Understanding when and why to write asynchronous code is as important as understanding the programming language syntax required to implement it. Not all scenarios will receive any measurable benefit from an asynchronous solution. And given the additional complexity of writing and maintaining asynchronous code, you might as well stick with a synchronous version in those cases. There are two primary situations when you should consider an asynchronous solution. IO bound operations involve some form of relatively slow input or output. This could be reading and writing data to and from a text file. Making an API call to a web service or querying a database. CPU bound operations involve intensive processing. This could include iterating over very large data sets or performing lots of complex mathematical calculations. If run on your program's main UI thread both of these could block input from your user while the operations…

Contents