Home
Options

Dumping the Util ProgressBar and the visible property

I hope the answer isn't embarrassingly simple. Oh well, here goes - If I dump a progress bar, it's visible. I make the visible property false, then immediately true the control is never visible on the results again. Code below.

However, if I uncomment that one line (where I'm dumping the same object, but a second time) it will indeed update the change to the results. Albeit, with some annoying visible redraw/flickering. Still, it mostly works that way. But why, and am I using the control incorrectly?

C# program, and using licensed Linqpad version 8:

void Main()
{
    var pb = new Util.ProgressBar("processing...");
    pb.Dump();
    pb.Percent = 25;
    Thread.Sleep(500);

    pb.Visible = false;
    pb.Visible = true;

    pb.Percent = 50;
    pb.Caption = "New caption";
    //pb.Dump();
    Thread.Sleep(500);
}

Comments

  • Options

    It wasn't designed to be repeatedly hidden and shown, so this scenario hasn't been tested. It was also written before LINQPad's controls where designed, so uses a more primitive rendering strategy.

    Do you need it to behave this way?

  • Options

    @JoeAlbahari said:

    ...

    Do you need it to behave this way?

    Yeah, that was just a POC for the question. So, I have a utility with a UI that I render in the Main method that looks like the following screenshot. When the execution finishes we're left with that UI and the Linqpad status bar says "Query Successful."

    For example, the "Add Prefix/Suffix" button would be clicked sometime after the query was finished, whenever the user had finished configuring the state of the form controls and was ready. Clicking the button would call method "AddPrefixSuffix" and do the processing.

    I intended to add some sort of progress bar to the processing in case of large sets of items (otherwise, it just appears to be locked up when it's not).

    My idea was to create and dump a not-visible progress bar inside the main method and have it appear at the top of the results above the "Enter prefix here" textbox (but not visible). When a button is clicked to do some work, code inside the AddPrefixSuffix method would make the progress bar visible, do the work and increment the progress bar, and make it not visible when processing was complete.

    I had even worse results using the other type of progress bar (the one where it appears in the status bar at the bottom) because it seems that one is truly only visible while the linqpad query is running.

    It's not the end of the word that I can't do this. I can just leave the progress bar visible from the get-go and be done with it. I just wondered if maybe I wasn't understanding something, and when I can't get it to work the way I want it drives me crazy - LOL

  • Options

    No worries - it looks like a simple fix. It should be in next week's beta.

  • Options

    There has been a slight (and possibly unintended) change in behaviour which I think may be related to this fix and it means that the Progress bar is no longer visible when it is initially dumped.

    The following script illustrates the change

    var pb = new Util.ProgressBar("Initialising, please wait ...").Dump("");
    Thread.Sleep(5000);
    
    for (int i = 1; i <= 100; i++)
    {
        pb.Caption = i + "% Complete";
        pb.Percent = i;
        Thread.Sleep(1);
    }
    
    

    Under Linqpad 5 and 8.1.6 the progress bar and the Initialising, please wait ... message are visible for the five seconds delay (which is to simulate a long initialisation progress). Under the beta version Linqpad 8.24, nothing appears on the screen during this delay.

  • Options

    Thanks - will take a look.

  • Options

    This should now be fixed in the 8.3.1 beta:
    https://www.linqpad.net/LINQPad8.aspx#beta

    Let me know how you get along.

  • Options

    Works great.
    Thank you.

  • Options

    I apologize for this taking so long. Just letting Joe know that I got the latest version and was able to accomplish what I intended with the progress bar in the scenario I discussed.

    Thanks so much for the quick enhancement!

Sign In or Register to comment.