Search code examples
c#console-applicationconsole.writeline

Console.WriteLine stops execution on Windows 10 until I press enter


I found no solution/answer to this.

private void LogToConsole(EventLog eventLog)
{
    var type = TypeToStringOfUniFormLength(eventLog.Type);
    Console.WriteLine($"# {type} {eventLog.Message}");
}

This i my "Event-Logger" and i have a very special behaviour. Most of time it's works great. My Console (in console-application) is updated, but sometimes it just stops at the line "Console.Writeline...". The Console is not updated and the execution pauses there. When i click in the console and hit Enter. The Console is updated an the execution continues. There is no specific scenario to reproduce. Is anybody familiar with this error, or even has a solution to this. My next work arround is to just not use a console-app for this.

thank you for your help in advance.


Solution

  • Windows 10 console automatically enters the Mark/Selection mode when you click it(no need to right-click->Mark, like it is with earlier windows consoles).

    This is what prevents the application from printing anything, but the application actually continues to work:

    The application itself keeps running, but nothing is written to the screen.

    Then

    When you exit the selection mode, the process will resume as normal.

    If it is not the case, then you will have to debug/dump your application to determine the culprit.