Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using a Lambda Expression within a Method
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
You can’t perform that action at this time.