Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Local Function instead of a Lambda expression
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));
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.