Created
July 22, 2017 08:05
-
-
Save christiannagel/59506b717fbe1b3afa6987899e8e1fe6 to your computer and use it in GitHub Desktop.
Local Function instead of a Lambda expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void AsynchronousPattern() | |
{ | |
WebRequest request = WebRequest.Create(url); | |
IAsyncResult result = request.BeginGetResponse(ReadResponse, null); | |
void ReadResponse(IAsyncResult ar) | |
{ | |
using (WebResponse response = request.EndGetResponse(ar)) | |
{ | |
Stream stream = response.GetResponseStream(); | |
StreamReader reader = new StreamReader(stream); | |
string content = reader.ReadToEnd(); | |
Console.WriteLine(content.Substring(0, 100)); | |
Console.WriteLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment