I finished! On to the next chapter

Outline

Asynchronous Process

So where does C# get its performance? I have 3 keywords for you:

  • Async
  • Task
  • Await

The use of these keywords optimize thread utilization by use of:

  • A state machine
  • A pool of threads
  • Basically, no thread gets a rest

Your machine has multiple cores that allows it to multi-task. C# unleashes your machine's:

  • Raw Speed
  • Fast Performance

Allows for your applications to remain responsive even under heavy load.

The Super Market Analogy

Imagine the supermarket scenario where you have a one cashier serving several shoppers. Consider the shopper a task, while the cash register is the state machine and the cashier is the thread that does the work.

In this scenario, the single cashier can only process one shopper at a time.

Think of the wait time the cashier spends waiting for the shopper to:

  • Load their goods on the counter
  • Retrieve payment from their purse or wallet

Async Scenario

Let's imagine for a moment that all the cash registers are part of one state machine. Each shopper is a task that can go to any cash register to checkout when there are done. This would be equivalent to:

  • A query running on the database
  • A request to a website
  • Opening a file to gather its contents

Cashiers are repurposed from other tasks to help process shoppers. As new customer come to any open check stand, cashiers head over to begin processing the next shopper.

In the next video, as we begin to implement the Repository Pattern, we'll begin making calls to the Db Context in an async manner to optimize thread utilization and maximizing your machine's potential.