Olivine-Labs / Alchemy-Websockets

An extremely efficient C# WebSocket server.
http://AlchemyWebsockets.net
Other
309 stars 105 forks source link

Can't exit the server application programmatically #81

Open limey98 opened 11 years ago

limey98 commented 11 years ago

I'm using a server mostly ripped from the example:

static void Main (string[] args)
{
    WebSocketServer aServer = new WebSocketServer (19568, IPAddress.Any)
    {
        OnReceive = OnReceive,
        OnConnected = OnConnected,
        OnDisconnect = OnDisconnect,
        TimeOut = new TimeSpan (0, 5, 0)
    };

    aServer.Start ();

    ConsoleKeyInfo info = Console.ReadKey (true);

    while (info.Key != ConsoleKey.Escape)
    {
        info = Console.ReadKey (true);
    }

    aServer.Stop ();
}

The server runs fine, but won't quit when I hit escape. The code is running all the way up to the .Stop() call (and thus, the end of the program), but something is stopping it from closing. Even if I comment out the .Start() and .Stop() calls, it still won't close. The only way is to remove the entire instantiation of the server. The close button of the console window does work, but I need to be able to stop it by hitting escape.