static void Main(string[] args) { var ctx = new SingleThreadSynchronizationContext(); SynchronizationContext.SetSynchronizationContext(ctx); var server = new Server(IPAddress.Any, 9001); Server.HostName = "localhost"; server.Run(); ctx.RunMessagePump(); }