Created
July 22, 2017 08:03
-
-
Save christiannagel/b8dc9eb60e1165264e7b2db2abe70624 to your computer and use it in GitHub Desktop.
Using a Lambda Expression within a Method
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
static void AsynchronousPattern() | |
{ | |
WebRequest request = WebRequest.Create(url); | |
IAsyncResult result = request.BeginGetResponse(ar => | |
{ | |
using (WebResponse response = request.EndGetResponse(ar)) | |
{ | |
Stream stream = response.GetResponseStream(); | |
var reader = new StreamReader(stream); | |
string content = reader.ReadToEnd(); | |
Console.WriteLine(content.Substring(0, 100)); | |
Console.WriteLine(); | |
} | |
}, null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment