Synchronous Execution

Example

public string GetDataSync()
{
    var client = new HttpClient();
    string result = client.GetStringAsync("https://example.com").Result; 
    Console.WriteLine("Data received");
    return result;
}

Flow:

Start method
↓
Wait for GetStringAsync to finish (blocking)
↓
Continue execution
↓
Print "Data received"

Asynchronous Execution

Example

public async Task<string> GetDataAsync()
{
    var client = new HttpClient();
    string result = await client.GetStringAsync("https://example.com");
    Console.WriteLine("Data received");
    return result;
}

Flow:

Start method
↓
Begin GetStringAsync (non-blocking)
↓
Return control to caller immediately
↓
Caller can do other work
↓
When GetStringAsync finishes → resume
↓
Print "Data received"

Side‑by‑Side Diagram

Synchronous:                  Asynchronous:

Caller                        Caller
  |                             |
  |--- Call method               |--- Call async method
  |--- Wait (blocked)            |--- Executes until await
  |--- Task completes            |--- Task runs in background
  |--- Continue                  |--- Caller continues work
                                |--- Task completes
                                |--- Method resumes after await
                                |--- Continue

Key Differences