I'm in the process of porting some server application from .NET Framework+WCF to .NET Core, but I'm having trouble managing the server exit. On our current WCF server, we allow quitting both from a WCF request, and from a console input:
    static void Main()
    {
        hExit = new ManualResetEvent(false);
        StartServer();
        Console.WriteLine("Server started. Press [Enter] to quit.");
        char key;
        while((key=WaitForKeyOrEvent(hExit)) != '\0' && key != '\r') { }
        Console.WriteLine();
        StopServer();
    }
    private static char WaitForKeyOrEvent(System.Threading.WaitHandle hEvent)
    {
        const int Timeout = 500;
        bool dueToEvent = false;
        while(!Console.KeyAvailable)
        {
            if(hEvent.WaitOne(Timeout, false))
            {
                dueToEvent = true;
                break;
            }
        }
        char ret = '\0';
        if(!dueToEvent)
        {
            ret = Console.ReadKey().KeyChar;
            if(ret == '\0')
                ret = char.MaxValue;
        }
        return ret;
    }
    ...
    class ServerObj : IMyWcfInterface
    {
        void IMyWcfInterface.ExitServer() { hExit.Set(); }
    }
Would this approach also work in .NET Core? (using some other tech than WCF of course, since it was abandoned) I vaguely remember hearing that KeyAvailable/ReadKey might not work for an application in a Docker Container, and use of Containers is one of the "end goals" of migrating to .NET Core...