const data = async () => {
 const got = await fetch(‘https://jsonplaceholder.typicode.com/todos/1');
 
 console.log(await got.json())
 }
 
 data();

Nowadays, Asynchronous programming is very popular with the help of the async and await keywords in C#. When we are dealing with UI, and on button click, we use a long-running method like reading a large file or something else which will take a long time, in that case, the entire application must wait to complete the whole task. In other words, if any process is blocked in a synchronous application, the whole application gets blocked, and our application stops responding until the whole task completes.

  • Async does not create threads.
  • Async uses the concept of state machine internally.
  • Async is a form of concurrency.

--

--

Photo by Lukas Blazek on Unsplash

Stacks are collections of data that follow the FILO(First In Last Out) data flow, stacks have severally methods which include:

  • Push(); => adds data to the top of the stack.
  • Pop(); => removes data from the top of the stack.
  • Peek(); => returns the value on the top of the stack without making any changes to the stack.

Queues are collections of that follow the FIFO(First In First Out) data flow, queues have some of these basic operations:

  • Enqueue(); => adds new data at the end of the queue.
  • Dequeue(); => removes data from the front of the queue.
  • Peek(); => returns the value at the beginning of the queue without making any changes to the queue.

Note: Queues are good for enforcing fairness, like in games or in any area you want First In First Out data to be enforced.

--

--