server.OnDataReceived += async (sender, e) =>
{
var bytesRead = 0;
do
{
// Read buffer, discarding data
bytesRead = e.Stream.Read(new byte[1024], 0, 1024);
}
while (bytesRead > 0 && e.Stream.DataAvailable);
// Simulate long running task
Console.WriteLine($"Doing some heavy response processing now. [{Thread.CurrentThread.ManagedThreadId}]");
await Task.Delay(3000);
Console.WriteLine($"Finished processing. [{Thread.CurrentThread.ManagedThreadId}]");