Skip to content

Synchronous Programming

SameerK-MSFT edited this page Aug 12, 2021 · 7 revisions

Overview

It is strongly recommended to use async programming practices for better performance and responsive apps. However, some legacy apps cannot use asynchronous programming.

MSAL dotnet is based on Task based Asynchronous Pattern (TAP). This page provides links to guidance about how to use async methods in a synchronous way. This has no one solution that fits all. So various best practices are recommended.

Asynchronous programming

If you are not familiar with asynchronous programming, this article will get you familiarized with it. Asynchronous programming with async and await

You can check for courses on linkedin: Advanced Programming in C#

Calling Asynchronous methods from Synchronous code

There are several ways to run asynchronous code from a synchronous code. Various links are listed here.

Task Run Synchronously

Waits for task to complete

Wait to get result

If you need to run multiple tasks at a time prior to wrapping them, it may be useful to take a look at this one. Consuming the Task-based Asynchronous Pattern

Also, watch out for exceptions and deadlocks.

Getting started with MSAL.NET

Acquiring tokens

Web Apps / Web APIs / daemon apps

Desktop/Mobile apps

Advanced topics

FAQ

Other resources

Clone this wiki locally