Home

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

  • 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?

  • @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

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

Sign In or Register to comment.