Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Node.NET: Non blocking API .NET
using System;
using System.IO;
using System.Net;
using System.Security.AccessControl;
using System.Text;
namespace SimpleExample
class Program
private const int BUFFER_SIZE = 10000;
static void Main(string[] args)
// So we need to read file in non blocking way,
// request some stuff from google and exit..
var file = new FileStream("Program.cs", FileMode.Open, FileAccess.Read,
FileShare.None, BUFFER_SIZE, true);
var buffer = new byte[BUFFER_SIZE];
file.BeginRead(buffer, 0, BUFFER_SIZE,
r =>
var read = file.EndRead(r);
var stuff = Encoding.Default.GetString(buffer, 0, read);
// Lets go futher... lets load some stuff from web
var url = "";
var req = WebRequest.Create(url);
r2 =>
var resp = req.EndGetResponse(r2);
Console.WriteLine("{0} headers recieved.",
}, null);
}, 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.