none
Console.WriteLine stops outputting text...

    Question

  • [[edit - turned out I had a bug in my code.]]

    Ok...  Here is the deal...

    1. Visual Studio 2015 Professional
    2. C#
    3. Console application.

    The console application runs continuously and will eventually be setup to be executed, started and stopped by a tool like Windows Task Scheduler...

    The process needs to monitor certain things and runs continuously.

    To show information about the process, I'm using both a text logging approach and a console.writeline to output it to the screen so we can see activity...  For some reason the process has stopped outputing to the console after a couple hours of processing, but is still writing to the text file, so I know that the process is active...

    Something I'm missing here?  Do I need to clear the console periodically?

    Thanks!


    • Edited by RichV12 Tuesday, May 17, 2016 12:41 PM
    Friday, May 13, 2016 1:43 PM

Answers

  • Good day all...

    It is working now...  I had a bug in the code.

    Thanks for your input.

    • Marked as answer by RichV12 Tuesday, May 17, 2016 12:40 PM
    Tuesday, May 17, 2016 12:40 PM

All replies

  • There doesn't seem to be a limit to the number of lines you can write to a Console.

    However there is a BufferHeight value, 32kb by default?, so maybe there is a hangup there.

    Or maybe the hang-up is in the code somewhere else?


    Friday, May 13, 2016 2:02 PM
  • The code/process is still running...  As indicated by the text file...

    The method that is used for the logging and console output does a Console.WriteLine(mytextstring) and outputs the same text to the log file...

    The code is about as dead simple as it can get...

    The code ran for about 4 hours or so before stopping the console output...  But, the text was still logging and it ran all night until this morning at 9:30am when I stopped the process to investigate this issue.

    Maybe a Console.Clear is appropriate every hour or so?  Is there any way to figure out if the buffer is getting close to full?  I'm hesitant to clear it every hour as the process logging could be higher depending on the volume of transactions?

    Friday, May 13, 2016 2:22 PM
  • >Something I'm missing here?  Do I need to clear the console periodically?

    No. There is no limit.  Can you create a simple repro?

    David


    David http://blogs.msdn.com/b/dbrowne/

    Friday, May 13, 2016 2:35 PM
  • Maybe you could just test that Clear.

    There is mention of Memory BufferArea and such.

    Is there a process that could trample the Console Memory Buffer Area? Antivirus maybe?

    Or how do you write to your txt file? is all the lines residing in Memory at the same time?

    I'll run a test with Console writing for 4-5 hours and see if it crashes.

    Friday, May 13, 2016 2:42 PM
  • I'm rerunning the process...  Will see what happens this time... Maybe it was just a fluke...  I haven't seen behaviour like this before in any console app...

    Anyway, don't put any effort into this yet...  I will update the post if it occurs again...

    Friday, May 13, 2016 2:45 PM
  • Note that if you send the "Pause" key to your console window it will block writing to the console.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Friday, May 13, 2016 2:49 PM
  • Good day all...

    It is working now...  I had a bug in the code.

    Thanks for your input.

    • Marked as answer by RichV12 Tuesday, May 17, 2016 12:40 PM
    Tuesday, May 17, 2016 12:40 PM