Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Terminus Code Example 1
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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; } } } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 0,14 sec, absolute running time: 5,46 sec, cpu time: 1,2 sec, average memory usage: 36 Mb, average nr of threads: 21
edit mode
|
history
|
discussion
FIRST <!DOCTYPE html> <html> <head> <title>Stack <!DOCTYPE html> <html> <head> <title>Stack