Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Terminus Code Example 1
//async // Task 1. Explain what this is doing. Walk through code // Task 2. Explain what the loop is doing // Task 3. Show 800 characters of the request // Task 4. Extract and display only the page Title 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<2; 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
assignment no.3.cs
breadbank
Range List for C#
12
Interlocked Class (atomic operations)
bytes to string to bytes.
shuffle2
Catch redirect link
Understandiing Virtual, Override, New Keyword in C#
const