[go: up one dir, main page]

0% found this document useful (0 votes)
9 views1 page

A Sync A Wait Example

Learn how async/await makes asynchronous programming easy

Uploaded by

cygdhruvamin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

A Sync A Wait Example

Learn how async/await makes asynchronous programming easy

Uploaded by

cygdhruvamin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System;

using System.Net.Http;
using System.Threading.Tasks;

class AsyncAwaitExample
{
static async Task Main()
{
Console.WriteLine("Fetching data...");
string data = await FetchDataAsync();
Console.WriteLine("Data length: " + data.Length);
}

static async Task<string> FetchDataAsync()


{
using HttpClient client = new HttpClient();
return await client.GetStringAsync("https://example.com");
}
}

You might also like