none
time to print to screen during long recursion RRS feed

  • Question

  • i'm doing an InOrder scan of a binary tree that is quite large.  while i'm doing this my monkey at the keys (me) has to wait a long time for proof of life from my valiant and hard-working recursion function. 

    during which time  I'd like to put some 'work in progress' sign of life on the screen but my 'print' statement has no time to refresh and nothing appears on the screen but stillness and worry.

    I've tried using

    Thread.Sleep(5); 

    after the print statement in my recursion but no go.

    BadButBit


    my code is perfect until i don't find a bug

    Friday, November 2, 2018 10:06 PM

Answers

  • What kind of application? Console? WinForms? Other?

    Where are you trying to show the status? On the console? In a textbox?
    In a label? Other?

    If in a control then you should invoke Refresh() or Update() immediately 
    after changing the contents.

    - Wayne

    • Marked as answer by Christ Kennedy Friday, November 2, 2018 11:13 PM
    Friday, November 2, 2018 11:00 PM

All replies

  • What kind of application? Console? WinForms? Other?

    Where are you trying to show the status? On the console? In a textbox?
    In a label? Other?

    If in a control then you should invoke Refresh() or Update() immediately 
    after changing the contents.

    - Wayne

    • Marked as answer by Christ Kennedy Friday, November 2, 2018 11:13 PM
    Friday, November 2, 2018 11:00 PM
  • thanks.

    i've since discovered that I can print to the form's text using a sleep() call but i still can't print to the textbox.

    it looks like there's something wrong with my textbox.


    my code is perfect until i don't find a bug

    Friday, November 2, 2018 11:13 PM

  •  i still can't print to the textbox.


    Did you try this with your textbox?

    textBox1.Text = "Some new text";
    textBox1.Refresh();
    

    - Wayne


    Friday, November 2, 2018 11:18 PM