Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
async example with HttpClient
//async using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Net.Http; using System.Threading.Tasks; using System.Threading; namespace Rextester { public class Program { public static void Main(string[] args) { for(int i=0; i<10; i++) { Test(); //async, passes through immediately } Console.WriteLine("FIRST"); //prints sooner than pages Thread.Sleep(5000); //just to get the output from Test() } static async void Test() { var r = await DownloadPage("http://stackoverflow.com"); Console.WriteLine(r.Substring(0, 50)); } static async Task<string> DownloadPage(string url) { using(var client = new HttpClient()) { using(var r = await client.GetAsync(new Uri(url))) { string result = await r.Content.ReadAsStringAsync(); return result; } } } } }
run
|
edit
|
history
|
help
0
ProWIN2
Geração de HASH do SKU pra enviar para Vtex
asdxsxsd
9
Sample Code
Pos and Neg
first index of a substring in a given string
Ccc
generics one more doubt-stack overflow exception
C# URI parts url